Repository navigation
342 lines (315 loc) · 13.7 KB
/
Copy pathrelease.yml
File metadata and controls
342 lines (315 loc) · 13.7 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
# Builds every package of D.E.V. Launcher and publishes them on a GitHub release.
#
# Push a tag that matches Cargo.toml's version (`v1.0.0`) to release. An `-alpha` or `-rc`
# version becomes a GitHub pre-release. Run it by hand (Actions → Release →
# Run workflow) to build everything without publishing.
#
# Files (the launcher reads its own updates with the same names it uses for the apps):
# dev-launcher-macos-universal.dmg
# dev-launcher-windows-{x64,arm64}-setup.exe (the launcher itself, which installs itself),
# dev-launcher-windows-{x64,arm64}-portable.zip
# dev-launcher-linux-{x86_64,aarch64}.{AppImage,deb,rpm,pkg.tar.zst,tar.gz}
# SHA256SUMS.txt, PKGBUILD (AUR: dev-launcher-bin)
#
# Optional secrets:
# macOS signing + notarization: MACOS_CERTIFICATE_P12 (base64), MACOS_CERTIFICATE_PASSWORD,
# MACOS_SIGN_IDENTITY ("Developer ID Application: …"), APPLE_ID, APPLE_TEAM_ID, APPLE_APP_PASSWORD.
# Without them the app is signed ad hoc.
# AUR: AUR_SSH_PRIVATE_KEY pushes the PKGBUILD to aur.archlinux.org/dev-launcher-bin.
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
version:
name: Version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: v
run: |
version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
echo "version=$version" >> "$GITHUB_OUTPUT"
if [[ "$GITHUB_REF" == refs/tags/* && "$GITHUB_REF_NAME" != "v$version" ]]; then
echo "::error::Tag $GITHUB_REF_NAME doesn't match Cargo.toml version $version"
exit 1
fi
linux:
name: Linux ${{ matrix.arch }}
needs: version
strategy:
fail-fast: false
matrix:
include:
- { runner: ubuntu-22.04, arch: x86_64, deb_arch: amd64, nfpm: x86_64 }
- { runner: ubuntu-22.04-arm, arch: aarch64, deb_arch: arm64, nfpm: arm64 }
runs-on: ${{ matrix.runner }}
env:
VERSION: ${{ needs.version.outputs.version }}
ARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Build
run: cargo build --release --locked
- name: Test
run: cargo test --release --locked
- name: Archive (.tar.gz, used by the AUR package)
run: |
mkdir -p dist stage/dev-launcher/icons
cp target/release/dev-launcher packaging/linux/dev-launcher.desktop LICENSE stage/dev-launcher/
cp assets/icons/app-icon-{16,32,48,64,128,256,512}.png assets/brand/app-icon.svg stage/dev-launcher/icons/
tar -C stage -czf "dist/dev-launcher-linux-$ARCH.tar.gz" dev-launcher
- name: Packages (.deb, .rpm, Arch)
env:
NFPM_ARCH: ${{ matrix.deb_arch }}
run: |
curl -sSfL "https://github.com/goreleaser/nfpm/releases/download/v2.41.1/nfpm_2.41.1_Linux_${{ matrix.nfpm }}.tar.gz" | tar -xz nfpm
./nfpm pkg -f packaging/linux/nfpm.yaml -p deb -t "dist/dev-launcher-linux-$ARCH.deb"
./nfpm pkg -f packaging/linux/nfpm.yaml -p rpm -t "dist/dev-launcher-linux-$ARCH.rpm"
./nfpm pkg -f packaging/linux/nfpm.yaml -p archlinux -t "dist/dev-launcher-linux-$ARCH.pkg.tar.zst"
- name: AppImage
run: |
app=AppDir
install -Dm755 target/release/dev-launcher "$app/usr/bin/dev-launcher"
install -Dm644 packaging/linux/dev-launcher.desktop "$app/usr/share/applications/dev-launcher.desktop"
for s in 16 32 48 64 128 256 512; do
install -Dm644 "assets/icons/app-icon-$s.png" "$app/usr/share/icons/hicolor/${s}x${s}/apps/dev-launcher.png"
done
cp packaging/linux/dev-launcher.desktop "$app/"
cp assets/icons/app-icon-256.png "$app/dev-launcher.png"
ln -s usr/bin/dev-launcher "$app/AppRun"
curl -sSfL -o appimagetool "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage"
chmod +x appimagetool
APPIMAGE_EXTRACT_AND_RUN=1 ./appimagetool --no-appstream "$app" "dist/dev-launcher-linux-$ARCH.AppImage"
- uses: actions/upload-artifact@v6
with:
name: linux-${{ matrix.arch }}
path: dist/*
if-no-files-found: error
windows:
name: Windows ${{ matrix.arch }}
needs: version
strategy:
fail-fast: false
matrix:
include:
- { runner: windows-latest, arch: x64 }
- { runner: windows-11-arm, arch: arm64 }
runs-on: ${{ matrix.runner }}
env:
VERSION: ${{ needs.version.outputs.version }}
ARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Clang (ring needs it on ARM64)
if: matrix.arch == 'arm64'
shell: pwsh
run: |
if (-not (Get-Command clang -ErrorAction SilentlyContinue)) {
choco install llvm -y --no-progress
"C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
}
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Build
run: cargo build --release --locked
- name: Test
run: cargo test --release --locked
- name: Portable zip
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "dist", "stage\D.E.V. Launcher" | Out-Null
Copy-Item target\release\dev-launcher.exe, LICENSE "stage\D.E.V. Launcher\"
Compress-Archive -Path "stage\D.E.V. Launcher" -DestinationPath "dist\dev-launcher-windows-$env:ARCH-portable.zip"
# The setup is the launcher itself: started as "…-setup.exe" it shows its own install screen.
- name: Setup
shell: pwsh
run: Copy-Item target\release\dev-launcher.exe "dist\dev-launcher-windows-$env:ARCH-setup.exe"
- uses: actions/upload-artifact@v6
with:
name: windows-${{ matrix.arch }}
path: dist/*
if-no-files-found: error
macos:
name: macOS universal
needs: version
runs-on: macos-15
env:
VERSION: ${{ needs.version.outputs.version }}
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- uses: Swatinem/rust-cache@v2
with:
key: release
- name: Test
run: cargo test --release --locked
- name: Build (Apple silicon + Intel)
run: |
cargo build --release --locked --target aarch64-apple-darwin
cargo build --release --locked --target x86_64-apple-darwin
- name: App bundle
run: |
app="stage/D.E.V. Launcher.app"
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
lipo -create -output "$app/Contents/MacOS/dev-launcher" \
target/aarch64-apple-darwin/release/dev-launcher target/x86_64-apple-darwin/release/dev-launcher
lipo -archs "$app/Contents/MacOS/dev-launcher"
sed "s/@VERSION@/$VERSION/g" packaging/macos/Info.plist > "$app/Contents/Info.plist"
plutil -lint "$app/Contents/Info.plist"
set=AppIcon.iconset; mkdir -p "$set"
for s in 16 32 128 256 512; do
sips -z $s $s assets/icons/app-icon-macos-1024.png --out "$set/icon_${s}x${s}.png" >/dev/null
d=$((s * 2)); sips -z $d $d assets/icons/app-icon-macos-1024.png --out "$set/icon_${s}x${s}@2x.png" >/dev/null
done
iconutil -c icns "$set" -o "$app/Contents/Resources/AppIcon.icns"
# The menu bar icon runs from a helper app of its own (see Helper-Info.plist).
helper="$app/Contents/Library/LoginItems/D.E.V. Launcher Helper.app"
mkdir -p "$helper/Contents/MacOS" "$helper/Contents/Resources"
cp "$app/Contents/MacOS/dev-launcher" "$helper/Contents/MacOS/dev-launcher"
sed "s/@VERSION@/$VERSION/g" packaging/macos/Helper-Info.plist > "$helper/Contents/Info.plist"
plutil -lint "$helper/Contents/Info.plist"
- name: Sign
run: |
app="stage/D.E.V. Launcher.app"
helper="$app/Contents/Library/LoginItems/D.E.V. Launcher Helper.app"
if [ -n "$MACOS_CERTIFICATE_P12" ]; then
kc=build.keychain; pw=$(uuidgen)
security create-keychain -p "$pw" $kc
security default-keychain -s $kc
security unlock-keychain -p "$pw" $kc
echo "$MACOS_CERTIFICATE_P12" | base64 --decode > cert.p12
security import cert.p12 -k $kc -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$pw" $kc >/dev/null
rm cert.p12
# Inside out: the helper first, then the app that contains it.
codesign --force --options runtime --timestamp --sign "$MACOS_SIGN_IDENTITY" "$helper"
codesign --force --options runtime --timestamp --sign "$MACOS_SIGN_IDENTITY" "$app"
else
echo "::warning::No signing certificate: the app is signed ad hoc and Gatekeeper will warn on first open."
codesign --force --sign - "$helper"
codesign --force --sign - "$app"
fi
codesign --verify --deep --strict --verbose=2 "$app"
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: DMG
run: |
mkdir -p dist
pip install "dmgbuild>=1.6,<2"
dmgbuild -s packaging/macos/dmg-settings.py \
-D app="stage/D.E.V. Launcher.app" \
-D background=packaging/macos/dmg-background.tiff \
-D icon="stage/D.E.V. Launcher.app/Contents/Resources/AppIcon.icns" \
"D.E.V. Launcher" dist/dev-launcher-macos-universal.dmg
if [ -n "$MACOS_CERTIFICATE_P12" ]; then
codesign --force --timestamp --sign "$MACOS_SIGN_IDENTITY" dist/dev-launcher-macos-universal.dmg
fi
- name: Notarize
if: env.APPLE_ID != '' && env.MACOS_CERTIFICATE_P12 != ''
run: |
xcrun notarytool submit dist/dev-launcher-macos-universal.dmg --wait \
--apple-id "$APPLE_ID" --team-id "$APPLE_TEAM_ID" --password "$APPLE_APP_PASSWORD"
xcrun stapler staple dist/dev-launcher-macos-universal.dmg
- uses: actions/upload-artifact@v6
with:
name: macos-universal
path: dist/*
if-no-files-found: error
release:
name: Publish
needs: [version, linux, windows, macos]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
permissions:
contents: write
env:
VERSION: ${{ needs.version.outputs.version }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
with:
path: dist
merge-multiple: true
- name: AUR PKGBUILD
run: |
sha() { sha256sum "dist/dev-launcher-linux-$1.tar.gz" | cut -d' ' -f1; }
sed -e "s/@VERSION@/$VERSION/g" \
-e "s/@PKGVER@/${VERSION//-/}/g" \
-e "s/@SHA_X86_64@/$(sha x86_64)/" \
-e "s/@SHA_AARCH64@/$(sha aarch64)/" \
-e "s#@REPO@#$GITHUB_REPOSITORY#g" \
packaging/aur/PKGBUILD.in > dist/PKGBUILD
- name: Checksums
run: |
cd dist
sha256sum dev-launcher-* > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: GitHub release
# Published as the latest release even for a beta: the README's download links go through
# /releases/latest/download/, which skips pre-releases. Alphas and release candidates stay
# pre-releases.
run: |
flag="--latest"
[[ "$VERSION" == *-alpha* || "$VERSION" == *-rc* ]] && flag="--prerelease"
gh release create "$GITHUB_REF_NAME" dist/* --title "D.E.V. Launcher $VERSION" --generate-notes $flag
- uses: actions/upload-artifact@v6
with:
name: aur
path: dist/PKGBUILD
aur:
name: AUR
needs: release
runs-on: ubuntu-22.04
container: archlinux:base-devel
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
steps:
- uses: actions/download-artifact@v7
with:
name: aur
- name: Push dev-launcher-bin
run: |
if [ -z "$AUR_SSH_PRIVATE_KEY" ]; then
echo "::notice::AUR_SSH_PRIVATE_KEY isn't set; the PKGBUILD is on the release, push it by hand."
exit 0
fi
pacman -Sy --noconfirm git openssh
mkdir -p ~/.ssh
echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur && chmod 600 ~/.ssh/aur
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
export GIT_SSH_COMMAND="ssh -i ~/.ssh/aur"
git clone ssh://aur@aur.archlinux.org/dev-launcher-bin.git aur
cp PKGBUILD aur/
useradd -m builder && chown -R builder aur
(cd aur && su builder -c "makepkg --printsrcinfo" > .SRCINFO)
cd aur
git config user.name "D.E.V. Launcher release"
git config user.email "noreply@github.com"
git config --global --add safe.directory "$PWD"
git add PKGBUILD .SRCINFO
git commit -m "Update to $(grep -m1 '^pkgver=' PKGBUILD | cut -d= -f2)" || exit 0
git push origin HEAD:master