Repository navigation
454 lines (440 loc) · 17.8 KB
/
Copy pathrelease.yml
File metadata and controls
454 lines (440 loc) · 17.8 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
name: Release Linux packages
on:
push:
tags:
- 'v[0-9]*'
workflow_dispatch:
inputs:
tag:
description: 'Existing version tag to build and publish (e.g. v0.0.3)'
required: true
type: string
prerelease:
description: 'Publish as prerelease (skips stable channel, NUR, and AUR)'
required: false
default: false
type: boolean
permissions:
contents: read
concurrency:
group: release-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
prepare:
name: Validate tag and create draft release
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
tag: ${{ steps.meta.outputs.tag }}
prerelease: ${{ steps.meta.outputs.prerelease }}
steps:
- name: Determine release tag
id: meta
env:
INPUT_TAG: ${{ inputs.tag }}
REF_NAME: ${{ github.ref_name }}
INPUT_PRERELEASE: ${{ inputs.prerelease }}
run: |
tag=${INPUT_TAG:-$REF_NAME}
[[ $tag =~ ^v[0-9][a-zA-Z0-9._-]*$ ]] || { echo "Invalid release tag: $tag" >&2; exit 1; }
prerelease=false
if [[ $INPUT_PRERELEASE == true || $tag == *-* ]]; then
prerelease=true
fi
{
echo "tag=$tag"
echo "prerelease=$prerelease"
} >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ steps.meta.outputs.tag }}
persist-credentials: false
- name: Verify Cargo.toml version and installer tests
env:
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
run: |
cargo_ver=$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["version"])')
expected="v$cargo_ver"
if [[ $RELEASE_TAG != "$expected" ]]; then
echo "Tag $RELEASE_TAG does not match Cargo.toml version ($expected)" >&2
exit 1
fi
bash -n scripts/install.sh
shellcheck scripts/install.sh
python3 -m unittest discover -s scripts/tests -v
- name: Ensure draft GitHub Release exists
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
IS_PRERELEASE: ${{ steps.meta.outputs.prerelease }}
run: |
if gh release view "$RELEASE_TAG" --json isDraft >/tmp/rel.json 2>/dev/null; then
is_draft=$(python3 -c 'import json; print(json.load(open("/tmp/rel.json"))["isDraft"])')
if [[ $is_draft != True ]]; then
echo "Release $RELEASE_TAG is already published; publish a new tag instead of mutating an existing release." >&2
exit 1
fi
echo "Reusing existing draft release $RELEASE_TAG."
else
args=(release create "$RELEASE_TAG" --draft --generate-notes --title "GDS $RELEASE_TAG")
if [[ $IS_PRERELEASE == true ]]; then
args+=(--prerelease)
fi
gh "${args[@]}"
fi
nix:
name: Build NUR packages (x86_64-linux)
needs: prepare
runs-on: ubuntu-24.04
timeout-minutes: 180
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.prepare.outputs.tag }}
persist-credentials: false
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Check NUR evaluation
run: |
nix-env -f packaging/nix/nur.nix -qa '*' --meta --json \
--option restrict-eval true \
--option allow-import-from-derivation true \
--allowed-uris https://static.rust-lang.org \
--drv-path --show-trace \
-I nixpkgs="$(nix-instantiate --find-file nixpkgs)" -I "$PWD"
- name: Build Files and standalone portal
run: nix-build packaging/nix/nur.nix -A gds-files -A xdg-desktop-portal-gds --no-out-link
build:
name: Build ${{ matrix.target }} (x86_64)
needs: prepare
runs-on: ubuntu-24.04
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
target: [arch, debian-13, ubuntu-24.04, ubuntu-26.04, fedora-43, fedora-44]
env:
CARGO_BUILD_JOBS: '2'
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.prepare.outputs.tag }}
fetch-depth: 0
persist-credentials: false
- name: Build native packages from the release tag
env:
TARGET: ${{ matrix.target }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
case "$TARGET" in
arch)
python3 scripts/build-linux-package.py arch --engine docker --profile release --package-release 1 --release-tag "$RELEASE_TAG"
;;
debian-13)
python3 scripts/build-linux-package.py debian --release trixie --engine docker --profile release --package-release 1
;;
ubuntu-24.04)
python3 scripts/build-linux-package.py ubuntu --release noble --engine docker --profile release --package-release 1
;;
ubuntu-26.04)
python3 scripts/build-linux-package.py ubuntu --release resolute --engine docker --profile release --package-release 1
;;
fedora-43)
python3 scripts/build-rpm.py --fedora 43 --engine docker --profile release --package-release 1
;;
fedora-44)
python3 scripts/build-rpm.py --fedora 44 --engine docker --profile release --package-release 1
;;
esac
- name: Collect Files and Portal packages
env:
TARGET: ${{ matrix.target }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
mkdir -p dist
version=${RELEASE_TAG#v}
case "$TARGET" in
arch) dir=target/arch/arch-latest; suffix="-$version-1-x86_64.pkg.tar.zst" ;;
debian-13) dir=target/deb/debian-trixie; suffix="_${version}-1~debian13_amd64.deb" ;;
ubuntu-24.04) dir=target/deb/ubuntu-noble; suffix="_${version}-1~ubuntu24.04_amd64.deb" ;;
ubuntu-26.04) dir=target/deb/ubuntu-resolute; suffix="_${version}-1~ubuntu26.04_amd64.deb" ;;
fedora-*) dir="target/rpm/$TARGET/x86_64"; suffix="-$version-1.fc${TARGET#fedora-}.x86_64.rpm" ;;
*) exit 1 ;;
esac
cp "$dir/gds-files$suffix" "$dir/xdg-desktop-portal-gds$suffix" dist/
- uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.target }}
path: dist/*
if-no-files-found: error
retention-days: 7
- name: Save validated AUR recipe
if: matrix.target == 'arch'
uses: actions/upload-artifact@v4
with:
name: aur-gds-files
path: target/arch/arch-latest/aur/
include-hidden-files: true
if-no-files-found: error
retention-days: 7
smoke-native:
name: Smoke test ${{ matrix.target }} clean container
needs: [prepare, build]
runs-on: ubuntu-24.04
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- target: arch
image: archlinux:latest
distro: arch
- target: debian-13
image: debian:trixie-slim
distro: debian
- target: ubuntu-24.04
image: ubuntu:24.04
distro: ubuntu
- target: ubuntu-26.04
image: ubuntu:26.04
distro: ubuntu
- target: fedora-43
image: registry.fedoraproject.org/fedora:43
distro: fedora
- target: fedora-44
image: registry.fedoraproject.org/fedora:44
distro: fedora
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.prepare.outputs.tag }}
persist-credentials: false
- uses: actions/download-artifact@v4
with:
name: packages-${{ matrix.target }}
path: smoke-repo/releases/${{ needs.prepare.outputs.tag }}
- name: Generate smoke repository manifest
env:
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
mkdir -p smoke-repo/channels
python3 scripts/generate-release-manifest.py \
--tag "$RELEASE_TAG" \
--dir "smoke-repo/releases/$RELEASE_TAG"
printf '%s\n' "$RELEASE_TAG" > smoke-repo/channels/stable
- name: Verify fresh install, idempotency, CLI check, and uninstall
env:
IMAGE: ${{ matrix.image }}
DISTRO: ${{ matrix.distro }}
run: |
docker run --rm \
-v "$PWD/smoke-repo:/repo:ro" \
-v "$PWD/scripts/install.sh:/install.sh:ro" \
-e GDS_ALLOW_FILE_URL=1 \
-e GDS_DIST_URL=file:///repo \
-e DISTRO="$DISTRO" \
"$IMAGE" \
bash -euo pipefail -c '
case "$DISTRO" in
debian|ubuntu)
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends curl ca-certificates desktop-file-utils
portal_bin=/usr/libexec/xdg-desktop-portal-gds
;;
fedora)
dnf install -y curl ca-certificates desktop-file-utils
portal_bin=/usr/libexec/xdg-desktop-portal-gds
;;
arch)
pacman -Syu --noconfirm curl ca-certificates desktop-file-utils
portal_bin=/usr/lib/xdg-desktop-portal-gds
;;
esac
bash /install.sh --yes --with-portal
gds-files --help >/dev/null
"$portal_bin" --help >/dev/null
desktop-file-validate /usr/share/applications/io.github.GanDesktop.GdsFiles.desktop
bash /install.sh --yes --with-portal
bash /install.sh --yes --uninstall
hash -r
if command -v gds-files >/dev/null || test -e "$portal_bin"; then
echo "Uninstall left a release binary behind" >&2
exit 1
fi
'
publish:
name: Publish release manifest, CDN assets, and atomic flip
needs: [prepare, build, smoke-native, nix]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.prepare.outputs.tag }}
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/download-artifact@v4
with:
pattern: packages-*
path: dist
merge-multiple: true
- name: Generate MANIFEST, SHA256SUMS, and upload to draft release
working-directory: dist
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
python3 ../scripts/generate-release-manifest.py --tag "$RELEASE_TAG" --dir .
cp ../scripts/install.sh ./install.sh
# GitHub normalizes '~' in asset names; keep package versions and CDN filenames intact.
python3 - <<'PY'
from pathlib import Path
manifest = Path("MANIFEST").read_text()
sums = Path("SHA256SUMS").read_text()
for line in sums.splitlines():
_, filename = line.split(" ", 1)
github_name = filename.replace("~", ".")
manifest = manifest.replace(filename, github_name)
sums = sums.replace(filename, github_name)
output = Path("../github-metadata")
output.mkdir(exist_ok=True)
(output / "MANIFEST").write_text(manifest)
(output / "SHA256SUMS").write_text(sums)
PY
gh release upload "$RELEASE_TAG" --clobber -- ./*.pkg.tar.zst ./*.deb ./*.rpm ../github-metadata/MANIFEST ../github-metadata/SHA256SUMS
- name: Upload immutable release assets to Cloudflare R2 and flip channel
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_ZONE_ID: ${{ vars.CLOUDFLARE_ZONE_ID }}
R2_BUCKET: ${{ vars.R2_BUCKET }}
DIST_BASE_URL: ${{ vars.DIST_BASE_URL }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
IS_PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
run: |
if [[ -z ${CLOUDFLARE_API_TOKEN:-} ]]; then
echo 'CLOUDFLARE_API_TOKEN is not set; skipping R2 and Cloudflare Worker deployment.'
exit 0
fi
: "${CLOUDFLARE_ACCOUNT_ID:?Set CLOUDFLARE_ACCOUNT_ID repository variable}"
: "${CLOUDFLARE_ZONE_ID:?Set CLOUDFLARE_ZONE_ID repository variable}"
bucket=${R2_BUCKET:-gds-pkgs}
base_url=${DIST_BASE_URL:-https://pkgs.gandesktop.dev}
npm ci --prefix packaging/cloudflare
for file in dist/*; do
name=$(basename "$file")
case "$name" in
*.pkg.tar.zst) ctype='application/zstd' ;;
*.deb) ctype='application/vnd.debian.binary-package' ;;
*.rpm) ctype='application/x-rpm' ;;
MANIFEST|SHA256SUMS|install.sh) ctype='text/plain; charset=utf-8' ;;
*) ctype='application/octet-stream' ;;
esac
npx --prefix packaging/cloudflare wrangler r2 object put \
"$bucket/releases/$RELEASE_TAG/$name" \
--file "$file" \
--content-type "$ctype" \
--cache-control 'public, max-age=31536000, immutable' \
--remote
done
curl --fail --show-error --silent --head "$base_url/releases/$RELEASE_TAG/MANIFEST" >/dev/null
curl --fail --show-error --silent --head "$base_url/releases/$RELEASE_TAG/SHA256SUMS" >/dev/null
while IFS= read -r line; do
[[ -n $line && $line != \#* ]] || continue
read -r _ _ _ _ _ _ fname _ <<< "$line"
curl --fail --show-error --silent --head "$base_url/releases/$RELEASE_TAG/$fname" >/dev/null
done < dist/MANIFEST
if [[ $IS_PRERELEASE != true ]]; then
printf '%s\n' "$RELEASE_TAG" > dist/stable
npx --prefix packaging/cloudflare wrangler r2 object put \
"$bucket/channels/stable" \
--file dist/stable \
--content-type 'text/plain; charset=utf-8' \
--cache-control 'public, max-age=60, must-revalidate' \
--remote
npx --prefix packaging/cloudflare cf -q cache purge \
-z "$CLOUDFLARE_ZONE_ID" \
-f \
--body "{\"files\":[\"$base_url/channels/stable\"]}"
npm run deploy --prefix packaging/cloudflare
fi
- name: Atomically publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: gh release edit "$RELEASE_TAG" --draft=false
aur:
name: Publish stable recipe to AUR
needs: [prepare, publish]
if: ${{ needs.prepare.outputs.prerelease != 'true' && vars.AUR_ENABLED == 'true' }}
runs-on: ubuntu-24.04
concurrency:
group: aur-gds-files
cancel-in-progress: false
steps:
- uses: actions/download-artifact@v4
with:
name: aur-gds-files
path: recipe
- name: Push the tested split package recipe
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
AUR_KNOWN_HOSTS: ${{ secrets.AUR_KNOWN_HOSTS }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
set -euo pipefail
: "${AUR_SSH_PRIVATE_KEY:?Set the AUR_SSH_PRIVATE_KEY repository secret}"
: "${AUR_KNOWN_HOSTS:?Set the verified AUR_KNOWN_HOSTS repository secret}"
ssh_dir=$(mktemp -d)
trap 'rm -rf "$ssh_dir"' EXIT
chmod 700 "$ssh_dir"
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$ssh_dir/key"
printf '%s\n' "$AUR_KNOWN_HOSTS" > "$ssh_dir/known_hosts"
chmod 600 "$ssh_dir/key" "$ssh_dir/known_hosts"
export GIT_SSH_COMMAND="ssh -i $ssh_dir/key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$ssh_dir/known_hosts"
git clone ssh://aur@aur.archlinux.org/gds-files.git aur
git -C aur checkout -B master
cp recipe/PKGBUILD recipe/.SRCINFO aur/
git -C aur config user.name 'GDS Release CI'
git -C aur config user.email 'noreply@github.com'
git -C aur add PKGBUILD .SRCINFO
if git -C aur diff --cached --quiet; then
echo 'AUR recipe is already up to date.'
else
git -C aur commit -m "Release $RELEASE_TAG"
git -C aur push origin master
fi
nur:
name: Publish stable revision for NUR and stable branch
needs: [prepare, publish, nix]
if: ${{ needs.prepare.outputs.prerelease != 'true' }}
runs-on: ubuntu-24.04
permissions:
contents: write
concurrency:
group: nur-release
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.prepare.outputs.tag }}
fetch-depth: 0
- name: Advance the stable and NUR release branches
run: git push origin HEAD:refs/heads/nur HEAD:refs/heads/stable
- name: Notify NUR after registration
if: vars.NUR_REPOSITORY != ''
env:
NUR_REPOSITORY: ${{ vars.NUR_REPOSITORY }}
run: |
curl --fail --show-error --silent --retry 3 \
--request POST --url-query "repo=$NUR_REPOSITORY" \
https://nur-update.nix-community.org/update