-
-
Notifications
You must be signed in to change notification settings - Fork 445
339 lines (292 loc) · 11.9 KB
/
release.yml
File metadata and controls
339 lines (292 loc) · 11.9 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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
# ── Extract release notes from CHANGELOG ───────────────────────────────────
changelog:
name: Extract release notes
runs-on: ubuntu-latest
outputs:
notes: ${{ steps.extract.outputs.notes }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Extract CHANGELOG section
id: extract
run: |
VERSION="${GITHUB_REF_NAME#v}"
# Extract lines between the versioned header and the next header (or EOF)
NOTES=$(awk "/^\[v${VERSION}\]/,/^\[v[0-9]/" CHANGELOG.md \
| head -n -1 \
| tail -n +2 \
| sed '/^[[:space:]]*$/{ N; /^\n[[:space:]]*$/d }')
if [[ -z "$NOTES" ]]; then
NOTES="See [CHANGELOG.md](CHANGELOG.md) for details."
fi
# Write multi-line output safely
{
echo "notes<<EOF_NOTES"
echo "$NOTES"
echo "EOF_NOTES"
} >> "$GITHUB_OUTPUT"
# ── Linux build ────────────────────────────────────────────────────────────
build-linux:
name: Linux x64
runs-on: ubuntu-latest
needs: changelog
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
libasound2-dev \
rpm
- name: Install npm dependencies
run: npm ci
- name: Sync SvelteKit types
run: npx svelte-kit sync
- name: Import GPG signing key
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: echo "$GPG_PRIVATE_KEY" | gpg --batch --import
- name: Build (release)
run: npm run tauri build -- --config '{"bundle":{"createUpdaterArtifacts":true}}' --bundles deb,appimage,rpm
env:
CI: true
- name: Sign Linux artifacts
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
for f in \
src-tauri/target/release/bundle/deb/*.deb \
src-tauri/target/release/bundle/rpm/*.rpm \
src-tauri/target/release/bundle/appimage/*.AppImage; do
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 \
--pinentry-mode loopback --detach-sign --armor "$f"
done
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: pomotroid-linux-x64
path: |
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/deb/*.deb.asc
src-tauri/target/release/bundle/appimage/*.AppImage
src-tauri/target/release/bundle/appimage/*.AppImage.asc
src-tauri/target/release/bundle/appimage/*.AppImage.sig
src-tauri/target/release/bundle/rpm/*.rpm
src-tauri/target/release/bundle/rpm/*.rpm.asc
if-no-files-found: error
# ── macOS build ────────────────────────────────────────────────────────────
build-macos:
name: macOS (universal)
runs-on: macos-latest
needs: changelog
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Rust stable (with universal targets)
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install npm dependencies
run: npm ci
- name: Sync SvelteKit types
run: npx svelte-kit sync
- name: Build (release, universal binary)
run: npm run tauri build -- --config '{"bundle":{"createUpdaterArtifacts":true}}' --bundles app,dmg --target universal-apple-darwin
env:
CI: true
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: pomotroid-macos-universal
path: |
src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app.tar.gz
src-tauri/target/universal-apple-darwin/release/bundle/macos/*.app.tar.gz.sig
if-no-files-found: error
# ── Windows build ──────────────────────────────────────────────────────────
build-windows:
name: Windows x64
runs-on: windows-latest
needs: changelog
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
outputs:
installer_hash: ${{ steps.hash.outputs.sha256 }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install npm dependencies
run: npm ci
- name: Sync SvelteKit types
run: npx svelte-kit sync
- name: Build (release)
run: npm run tauri build -- --config '{"bundle":{"createUpdaterArtifacts":true}}' --bundles nsis
env:
CI: true
- name: Compute installer hash
id: hash
shell: bash
run: |
hash=$(sha256sum src-tauri/target/release/bundle/nsis/*-setup.exe | cut -d' ' -f1)
echo "sha256=$hash" >> "$GITHUB_OUTPUT"
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: pomotroid-windows-x64
path: |
src-tauri/target/release/bundle/nsis/*-setup.exe
src-tauri/target/release/bundle/nsis/*-setup.exe.sig
src-tauri/target/release/pomotroid.exe
if-no-files-found: error
# ── Create draft GitHub Release ────────────────────────────────────────────
release:
name: Create draft release
runs-on: ubuntu-latest
needs: [changelog, build-linux, build-macos, build-windows]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: pomotroid-linux-x64
path: dist/linux
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: pomotroid-macos-universal
path: dist/macos
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: pomotroid-windows-x64
path: dist/windows
- name: Generate latest.json updater manifest
run: |
VERSION="${{ needs.changelog.outputs.version }}"
REPO="https://github.com/Splode/pomotroid"
PUB_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Derive actual filenames from the downloaded artifacts rather than
# constructing them from the tag version — the tag version may differ
# from the binary version in tauri.conf.json.
APPIMAGE_FILE=$(find dist/linux -name "*.AppImage" ! -name "*.sig" | head -1)
APPIMAGE_SIG=$(cat "${APPIMAGE_FILE}.sig" 2>/dev/null || echo "")
APP_TAR_FILE=$(find dist/macos -name "*.app.tar.gz" ! -name "*.sig" | head -1)
APP_TAR_SIG=$(cat "${APP_TAR_FILE}.sig" 2>/dev/null || echo "")
NSIS_FILE=$(find dist/windows -name "*-setup.exe" ! -name "*.sig" | head -1)
NSIS_SIG=$(cat "${NSIS_FILE}.sig" 2>/dev/null || echo "")
jq -n \
--arg version "$VERSION" \
--arg pub_date "$PUB_DATE" \
--arg notes "See $REPO/releases/tag/v$VERSION for release notes." \
--arg linux_url "$REPO/releases/download/v$VERSION/$(basename "$APPIMAGE_FILE")" \
--arg linux_sig "$APPIMAGE_SIG" \
--arg darwin_url "$REPO/releases/download/v$VERSION/$(basename "$APP_TAR_FILE")" \
--arg darwin_sig "$APP_TAR_SIG" \
--arg windows_url "$REPO/releases/download/v$VERSION/$(basename "$NSIS_FILE")" \
--arg windows_sig "$NSIS_SIG" \
'{
version: $version,
notes: $notes,
pub_date: $pub_date,
platforms: {
"linux-x86_64": { signature: $linux_sig, url: $linux_url },
"darwin-aarch64": { signature: $darwin_sig, url: $darwin_url },
"darwin-x86_64": { signature: $darwin_sig, url: $darwin_url },
"windows-x86_64": { signature: $windows_sig, url: $windows_url }
}
}' > latest.json
- name: Update Scoop manifest and commit latest.json
run: |
VERSION="${{ needs.changelog.outputs.version }}"
HASH="${{ needs.build-windows.outputs.installer_hash }}"
jq --arg v "$VERSION" --arg h "$HASH" \
'.version = $v | .hash = $h | .url = "https://github.com/Splode/pomotroid/releases/download/v\($v)/Pomotroid_\($v)_x64-setup.exe#/dl.exe"' \
pomotroid.json > pomotroid.json.tmp && mv pomotroid.json.tmp pomotroid.json
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pomotroid.json latest.json
git commit -m "chore: update Scoop manifest and latest.json to v${VERSION} [skip ci]"
git push origin HEAD:main
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
name: ${{ github.ref_name }}
body: ${{ needs.changelog.outputs.notes }}
files: |
dist/linux/**/*.deb
dist/linux/**/*.deb.asc
dist/linux/**/*.AppImage
dist/linux/**/*.AppImage.asc
dist/linux/**/*.rpm
dist/linux/**/*.rpm.asc
dist/macos/**/*.dmg
dist/macos/**/*.app.tar.gz
dist/windows/**/*-setup.exe
dist/windows/**/pomotroid.exe