-
Notifications
You must be signed in to change notification settings - Fork 1
343 lines (339 loc) · 13 KB
/
Copy pathpublish.yml
File metadata and controls
343 lines (339 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Release
on:
workflow_dispatch:
jobs:
checks:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get_tag.outputs.tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check HEAD has a tag
id: get_tag
run: |
TAG=$(git tag --points-at HEAD | head -n1)
if [ -z "$TAG" ]; then
echo "Error: HEAD commit has no tag. Please tag this commit before publishing."
exit 1
fi
echo "Found tag: $TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Check tag matches Cargo.toml version
run: |
TAG="${{ steps.get_tag.outputs.tag }}"
# Strip leading 'v' if present (v0.4.1 -> 0.4.1)
VERSION="${TAG#v}"
CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
if [ "$VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Tag version ($VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
echo "Tag matches Cargo.toml version: $VERSION"
- name: Check version not already on crates.io
run: |
TAG="${{ steps.get_tag.outputs.tag }}"
# Strip leading 'v' if present (v0.4.1 -> 0.4.1)
VERSION="${TAG#v}"
echo "Checking if $VERSION exists on crates.io..."
CRATE_NAME=$(grep -m1 '^name' Cargo.toml | sed 's/.*"\(.*\)".*/\1/')
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/$CRATE_NAME/$VERSION")
if [ "$HTTP_STATUS" = "200" ]; then
echo "Error: Version $VERSION already exists on crates.io"
exit 1
fi
echo "Version $VERSION not yet published, proceeding."
ci:
needs: checks
uses: ./.github/workflows/ci.yml
ui-tests:
needs: ci
uses: ./.github/workflows/ui-tests.yml
publish:
needs: ui-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install packages needed for build
run: sudo apt-get update && sudo apt-get install -y build-essential libgtksourceview-5-dev
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
create-release:
needs: [checks, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.checks.outputs.tag }}"
gh release create "$TAG" --title "$TAG" --generate-notes
appimage:
needs: [checks, create-release]
strategy:
matrix:
include:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Install packages needed for build
run: sudo apt-get update && sudo apt-get install -y build-essential libgtksourceview-5-dev librsvg2-bin libfuse2
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build release binary
run: cargo build --release
- name: Convert SVG icon to PNG
run: rsvg-convert -w 256 -h 256 assets/mergers.svg -o mergers.png
- name: Download appimagetool
run: |
curl -fsSL -o appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${{ matrix.arch }}.AppImage
chmod +x appimagetool
- name: Build AppImage
run: |
mkdir -p AppDir/usr/bin
cp target/release/mergers AppDir/usr/bin/mergers
cp assets/mergers.desktop AppDir/mergers.desktop
cp mergers.png AppDir/mergers.png
ln -s usr/bin/mergers AppDir/AppRun
./appimagetool --appimage-extract-and-run AppDir mergers-${{ matrix.arch }}.AppImage
- name: Upload AppImage to GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.checks.outputs.tag }}"
gh release upload "$TAG" mergers-${{ matrix.arch }}.AppImage --clobber
macos:
needs: [checks, create-release]
strategy:
matrix:
include:
- runner: macos-latest
arch: aarch64
- runner: macos-15-intel
arch: x86_64
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: brew install gtk4 gtksourceview5
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build release binary
run: cargo build --release
- name: Create tarball
run: tar -czf mergers-darwin-${{ matrix.arch }}.tar.gz -C target/release mergers
- name: Upload to GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.checks.outputs.tag }}"
gh release upload "$TAG" mergers-darwin-${{ matrix.arch }}.tar.gz --clobber
windows:
needs: [checks, create-release]
strategy:
fail-fast: false
matrix:
include:
- runner: windows-latest
msystem: UCRT64
package_prefix: mingw-w64-ucrt-x86_64
rust_target: x86_64-pc-windows-gnu
cargo_target_flag: "--target x86_64-pc-windows-gnu"
binary_path: target/x86_64-pc-windows-gnu/release/mergers.exe
arch: x86_64
- runner: windows-11-arm
msystem: CLANGARM64
package_prefix: mingw-w64-clang-aarch64
rust_target: aarch64-pc-windows-gnullvm
cargo_target_flag: "--target aarch64-pc-windows-gnullvm"
binary_path: target/aarch64-pc-windows-gnullvm/release/mergers.exe
arch: aarch64
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
- name: Set MSYS2 mirror for ARM64
if: matrix.msystem == 'CLANGARM64'
shell: msys2 {0}
run: |
echo 'Server = https://repo.msys2.org/mingw/$repo/' > /etc/pacman.d/mirrorlist.mingw
- name: Install MSYS2 packages (UCRT64)
if: matrix.msystem == 'UCRT64'
shell: msys2 {0}
run: |
pacman -S --noconfirm ${{ matrix.package_prefix }}-gtk4 ${{ matrix.package_prefix }}-gtksourceview5 ${{ matrix.package_prefix }}-pkgconf ${{ matrix.package_prefix }}-gcc
- name: Install MSYS2 packages (CLANGARM64)
if: matrix.msystem == 'CLANGARM64'
shell: msys2 {0}
run: |
pacman -S --noconfirm ${{ matrix.package_prefix }}-gtk4 ${{ matrix.package_prefix }}-gtksourceview5 ${{ matrix.package_prefix }}-pkgconf ${{ matrix.package_prefix }}-clang
- uses: actions/checkout@v6
- name: Install Rust
shell: msys2 {0}
run: |
export CARGO_HOME="$(pwd)/.cargo"
export RUSTUP_HOME="$(pwd)/.rustup"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
export PATH="$(pwd)/.cargo/bin:$PATH"
rustup target add ${{ matrix.rust_target }}
- name: Configure cargo linker
shell: msys2 {0}
run: |
mkdir -p .cargo
printf '[target.x86_64-pc-windows-gnu]\nlinker = "gcc"\n[target.aarch64-pc-windows-gnullvm]\nlinker = "clang"\n' > .cargo/config.toml
- name: Build release binary
shell: msys2 {0}
run: |
export CARGO_HOME="$(pwd)/.cargo"
export RUSTUP_HOME="$(pwd)/.rustup"
# Use only MSYS2 paths to avoid picking up link.exe from Visual Studio
export PATH="$(pwd)/.cargo/bin:/$MSYSTEM/bin:/usr/bin"
export PKG_CONFIG_ALLOW_CROSS=1
cargo build --release ${{ matrix.cargo_target_flag }}
- name: Bundle binary with DLLs
shell: msys2 {0}
run: |
mkdir -p dist
cp ${{ matrix.binary_path }} dist/
# Copy all required DLLs from MSYS2
ldd ${{ matrix.binary_path }} | grep -i "$MSYSTEM" | awk '{print $3}' | xargs -I{} cp {} dist/
# Copy GtkSourceView language specs and styles
mkdir -p dist/share
cp -r /$MSYSTEM/share/gtksourceview-5 dist/share/gtksourceview-5
# Copy GTK schema files
mkdir -p dist/share/glib-2.0/schemas
cp /$MSYSTEM/share/glib-2.0/schemas/gschemas.compiled dist/share/glib-2.0/schemas/
# Copy icon theme
mkdir -p dist/share/icons
cp -r /$MSYSTEM/share/icons/hicolor dist/share/icons/
cp -r /$MSYSTEM/share/icons/Adwaita dist/share/icons/ 2>/dev/null || true
- name: Create zip
shell: pwsh
run: Compress-Archive -Path dist\* -DestinationPath mergers-windows-${{ matrix.arch }}.zip
- name: Upload to GitHub release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.checks.outputs.tag }}"
gh release upload "$TAG" mergers-windows-${{ matrix.arch }}.zip --clobber
aur:
needs: [checks, appimage]
runs-on: ubuntu-latest
container: archlinux:base-devel
steps:
- name: Install dependencies
run: pacman -Sy --noconfirm git openssh
- name: Setup SSH
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
mkdir -p -m 700 /root/.ssh
echo "$AUR_SSH_KEY" > /root/.ssh/aur
chmod 600 /root/.ssh/aur
ssh-keyscan aur.archlinux.org >> /root/.ssh/known_hosts
- name: Clone AUR repo
run: GIT_SSH_COMMAND="ssh -i /root/.ssh/aur" git clone ssh://aur@aur.archlinux.org/mergers.git aur-repo
- name: Update PKGBUILD
run: |
TAG="${{ needs.checks.outputs.tag }}"
VERSION="${TAG#v}"
SHA=$(curl -sL "https://github.com/joske/mergers/archive/refs/tags/${TAG}.tar.gz" | sha256sum | cut -d' ' -f1)
cd aur-repo
sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
sed -i "s/^sha256sums=.*/sha256sums=('${SHA}')/" PKGBUILD
- name: Generate .SRCINFO
run: |
cd aur-repo
useradd -m builder
chown -R builder:builder .
su builder -c "makepkg --printsrcinfo > .SRCINFO"
- name: Commit and push
run: |
cd aur-repo
chown -R root:root .
git config user.name "Jos Dehaes"
git config user.email "jos.dehaes@gmail.com"
git add PKGBUILD .SRCINFO
git diff-index --quiet HEAD || { git commit -m "Update to ${{ needs.checks.outputs.tag }}" && GIT_SSH_COMMAND="ssh -i /root/.ssh/aur" git push; }
- name: Cleanup SSH key
if: always()
run: rm -f /root/.ssh/aur
homebrew:
needs: [checks, macos]
runs-on: ubuntu-latest
steps:
- name: Determine version
id: version
run: |
TAG="${{ needs.checks.outputs.tag }}"
VERSION="${TAG#v}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Compute SHA256 checksum
id: sha
run: |
TAG="${{ steps.version.outputs.tag }}"
URL="https://github.com/joske/mergers/releases/download/${TAG}/mergers-darwin-aarch64.tar.gz"
SHA=$(curl -sL "$URL" | shasum -a 256 | cut -d' ' -f1)
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Checkout tap repository
uses: actions/checkout@v6
with:
repository: joske/homebrew-mergers
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Update formula
env:
VERSION: ${{ steps.version.outputs.version }}
TAG: ${{ steps.version.outputs.tag }}
SHA: ${{ steps.sha.outputs.sha }}
run: |
cat > Formula/mergers.rb << EOF
class Mergers < Formula
desc "Visual diff and merge tool written in Rust with GTK4"
homepage "https://github.com/joske/mergers"
version "${VERSION}"
license "GPL-2.0-only"
url "https://github.com/joske/mergers/releases/download/${TAG}/mergers-darwin-aarch64.tar.gz"
sha256 "${SHA}"
depends_on :macos
depends_on "adwaita-icon-theme"
depends_on "gtk4"
depends_on "gtksourceview5"
def install
bin.install "mergers"
end
test do
assert_match version.to_s, shell_output("\#{bin}/mergers --version")
end
end
EOF
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/mergers.rb
git commit -m "Update mergers to ${{ steps.version.outputs.tag }}"
git push