Repository navigation
712 lines (687 loc) · 31.9 KB
/
Copy pathrelease.yml
File metadata and controls
712 lines (687 loc) · 31.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
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
name: Release
# Builds, signs, and publishes Hex for macOS, Windows, and Linux from one
# exact commit to the Anomaly release service (docs/releasing.md,
# docs/plans/release-service.md), split the way OpenCode's release is:
#
# - build jobs (Build desktop, build-macos, Windows installers, the AUR and
# Homebrew staging) run repository code: cargo, build.rs, makepkg,
# brew. They have no environment, no secrets, and no id-token, and they
# produce unsigned files.
# - sign and publish jobs run in the release environment. They check out only
# .github/release/ and run only those scripts and SHA-pinned actions, on
# artifacts they treat as data: they never build, install dependencies, or
# execute repository code or the artifacts.
# - every artifact carries a SHA256SUMS whose digest the job that made it
# reports as an output; every job that downloads it checks that digest
# (.github/release/verify-artifacts.sh), so nothing swapped in between
# jobs is signed or published.
#
# This file and .github/release/ are the security boundary for releases, and
# a ruleset lets only Dax change .github/ (docs/releasing.md).
#
# There is one environment, release, like OpenCode's: no approval, deployment
# policy dev and production. The service authorizes the publish jobs by their
# OIDC token: anomalyco/hex, this file, environment release, the dev channel
# from dev and stable from production (anomalyco/release registry/hex.json).
# Hex never uses the service's dev stage.
#
# Channels (.github/release/plan.sh):
# - dev: every push to dev (except docs/site/Markdown-only) publishes
# 0.0.0-dev-<run number> on the dev channel, as OpenCode numbers dev builds;
# a running release finishes and only the newest push waits behind it
# (the ones between are skipped). Only signed platforms are
# published. Versions are display text: installs follow the channel's
# current release and never compare versions.
# - check: a dispatch from dev builds, signs, and verifies the same and
# publishes nothing; its last job pushes and deletes a throwaway
# v0.0.0-test-<run> tag to prove it can tag.
# - stable: a dispatch from production publishes the crate version with every
# platform signed, the AUR, and Homebrew. Tags trigger nothing: only after
# everything published does the last job tag v<version> on the released
# commit and create the GitHub release, so a failed run leaves no tag. Deploy the production site afterwards with Site.
on:
workflow_dispatch:
inputs:
ref:
description: Commit, tag, or branch to release
required: true
default: production
channel:
description: check (build, sign, and verify; publish nothing), dev (the dev channel; run from dev), or stable (public)
type: choice
options: [check, dev, stable]
default: check
push:
branches: [dev]
# Docs and the site alone cut no dev build.
paths-ignore: ["docs/**", "site/**", "**/*.md"]
permissions:
contents: read
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'dev' }}
# Releases never cancel each other: the running one finishes, and of the
# pushes that land meanwhile only the newest waits (GitHub replaces an
# older pending run in the group), so a busy dev branch still publishes.
cancel-in-progress: false
defaults:
run:
shell: bash
env:
HEX_TEAM_ID: 5NZ4Q7NXJ4
jobs:
plan:
runs-on: ubuntu-24.04
outputs:
sha: ${{ steps.plan.outputs.sha }}
version: ${{ steps.plan.outputs.version }}
channel: ${{ steps.plan.outputs.channel }}
service: ${{ steps.plan.outputs.service }}
tag: ${{ steps.plan.outputs.tag }}
notes-url: ${{ steps.plan.outputs.notes-url }}
release-channel: ${{ steps.plan.outputs.release-channel }}
release-version: ${{ steps.plan.outputs.release-version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
sparse-checkout: |
/.github/release/
/Cargo.toml
/docs/releases/
sparse-checkout-cone-mode: false
persist-credentials: false
- id: plan
run: SHA=$(git rev-parse HEAD) bash .github/release/plan.sh
env:
EVENT: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
INPUT_REF: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'dev' }}
GH_TOKEN: ${{ github.token }}
# ---- Build: repository code; no environment, secrets, or id-token ----------
build:
needs: plan
uses: ./.github/workflows/build-desktop.yml
with:
sha: ${{ needs.plan.outputs.sha }}
version: ${{ needs.plan.outputs.release-version }}
channel: ${{ needs.plan.outputs.release-channel }}
# Hex.app as the release identity (anomaly.hex), ad-hoc signed; sign-macos
# signs it with the Developer ID.
build-macos:
needs: plan
runs-on: macos-26
timeout-minutes: 120
env:
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
HEX_BUILD_CHANNEL: ${{ needs.plan.outputs.release-channel }}
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
toolchain: stable
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
- name: Install the Metal toolchain
run: xcrun --sdk macosx metal --version || xcodebuild -downloadComponent MetalToolchain
- name: Build Hex.app
run: |
scripts/setup.sh
scripts/set-crate-version.sh "$PWD" "$HEX_VERSION"
bundle=$(HEX_RELEASE_UNSIGNED=1 scripts/build-app.sh)
mkdir -p "$RUNNER_TEMP/macos"
/usr/bin/ditto -c -k --sequesterRsrc --keepParent "$bundle" "$RUNNER_TEMP/macos/Hex.app.zip"
# The DMG window's background and Finder layout: data for sign-macos.sh.
cp packaging/macos/dmg/background.tiff "$RUNNER_TEMP/macos/dmg-background.tiff"
cp packaging/macos/dmg/DS_Store "$RUNNER_TEMP/macos/dmg-DS_Store"
- id: upload
uses: ./.github/release/upload
with:
name: build-macos-arm64
path: ${{ runner.temp }}/macos
# ---- Sign: release environment; only .github/release/ is checked out -------
# Signs Hex.app inside-out with the Developer ID, notarizes and staples it,
# and makes the updater zip and the DMG from the stapled app. Without the
# Apple values, dev and check go on without macOS; stable fails.
sign-macos:
needs: [plan, build-macos]
if: ${{ !cancelled() && needs.build-macos.result == 'success' }}
runs-on: macos-26
timeout-minutes: 90
environment: release
env:
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
CHANNEL: ${{ needs.plan.outputs.channel }}
outputs:
signed: ${{ steps.credentials.outputs.available }}
digest: ${{ steps.upload.outputs.digest }}
steps:
- &checkout-release
name: Check out the release scripts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- id: credentials
name: Require the Apple values
env:
CERTIFICATE: ${{ secrets.APPLE_SIGNING_CERTIFICATE }}
KEY: ${{ secrets.APPLE_NOTARY_KEY }}
KEY_ID: ${{ vars.APPLE_NOTARY_KEY_ID }}
ISSUER: ${{ vars.APPLE_NOTARY_ISSUER_ID }}
run: |
missing=
[ -n "$CERTIFICATE" ] || missing="$missing APPLE_SIGNING_CERTIFICATE"
[ -n "$KEY" ] || missing="$missing APPLE_NOTARY_KEY"
[ -n "$KEY_ID" ] || missing="$missing APPLE_NOTARY_KEY_ID"
[ -n "$ISSUER" ] || missing="$missing APPLE_NOTARY_ISSUER_ID"
if [ -z "$missing" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
elif [ "$CHANNEL" = stable ]; then
echo "::error::Stable releases need the macOS build, and the release environment lacks:$missing."
exit 1
else
echo "available=false" >> "$GITHUB_OUTPUT"
echo "No macOS targets: the release environment lacks$missing." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Download
if: steps.credentials.outputs.available == 'true'
uses: ./.github/release/download
with:
pattern: build-macos-arm64
digests: build-macos-arm64=${{ needs.build-macos.outputs.digest }}
- name: Import the certificate and notary key
if: steps.credentials.outputs.available == 'true'
run: bash .github/release/macos-credentials.sh "$RUNNER_TEMP/credentials"
env:
APPLE_SIGNING_CERTIFICATE: ${{ secrets.APPLE_SIGNING_CERTIFICATE }}
APPLE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_SIGNING_CERTIFICATE_PASSWORD }}
APPLE_NOTARY_KEY: ${{ secrets.APPLE_NOTARY_KEY }}
- name: Sign, notarize, and staple
if: steps.credentials.outputs.available == 'true'
run: bash .github/release/sign-macos.sh "$RUNNER_TEMP/in/build-macos-arm64/Hex.app.zip" "$RUNNER_TEMP/out"
env:
HEX_NOTARY_KEY_ID: ${{ vars.APPLE_NOTARY_KEY_ID }}
HEX_NOTARY_ISSUER: ${{ vars.APPLE_NOTARY_ISSUER_ID }}
- name: Remove the credentials
if: always() && steps.credentials.outputs.available == 'true'
run: |
security delete-keychain "$RUNNER_TEMP/credentials/signing.keychain-db" 2>/dev/null || true
rm -rf "$RUNNER_TEMP/credentials"
- id: upload
if: steps.credentials.outputs.available == 'true'
uses: ./.github/release/upload
with:
name: sign-macos
path: ${{ runner.temp }}/out
# Authenticode-signs both executables through Azure Artifact Signing.
# Without the Azure values, dev and check go on without Windows; stable
# fails.
sign-windows:
needs: [plan, build]
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: windows-latest
timeout-minutes: 30
environment: release
permissions:
contents: read
id-token: write
env: &windows-sign-env
CHANNEL: ${{ needs.plan.outputs.channel }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
outputs:
signed: ${{ steps.credentials.outputs.available }}
digest: ${{ steps.upload.outputs.digest }}
steps:
- *checkout-release
- &azure-credentials
id: credentials
name: Require the Azure values
run: |
missing=
for name in AZURE_CLIENT_ID AZURE_TENANT_ID AZURE_SUBSCRIPTION_ID AZURE_TRUSTED_SIGNING_ENDPOINT \
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE; do
[ -n "$(printenv "$name")" ] || missing="$missing $name"
done
if [ -z "$missing" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
elif [ "$CHANNEL" = stable ]; then
echo "::error::Stable releases need signed Windows builds, and the release environment lacks:$missing."
exit 1
else
echo "available=false" >> "$GITHUB_OUTPUT"
echo "No Windows targets: the release environment lacks$missing." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Download
if: steps.credentials.outputs.available == 'true'
uses: ./.github/release/download
with:
pattern: build-windows-*
digests: build-windows-x86_64=${{ needs.build.outputs.windows-x64-digest }} build-windows-aarch64=${{ needs.build.outputs.windows-arm64-digest }}
- name: Gather the executables
if: steps.credentials.outputs.available == 'true'
run: |
temp=$(cygpath -u "$RUNNER_TEMP")
mkdir -p "$temp/work" && cp "$temp"/in/build-windows-*/*.exe "$temp/work/"
- &azure-login
name: Sign in to Azure
if: steps.credentials.outputs.available == 'true'
uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
- &azure-sign
name: Sign
if: steps.credentials.outputs.available == 'true'
uses: azure/artifact-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2
with:
endpoint: ${{ env.AZURE_TRUSTED_SIGNING_ENDPOINT }}
signing-account-name: ${{ env.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
certificate-profile-name: ${{ env.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
files-folder: ${{ runner.temp }}\work
files-folder-filter: exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
description: Hex
description-url: https://github.com/anomalyco/hex
exclude-environment-credential: true
exclude-workload-identity-credential: true
exclude-managed-identity-credential: true
exclude-shared-token-cache-credential: true
exclude-visual-studio-credential: true
exclude-visual-studio-code-credential: true
exclude-azure-cli-credential: false
exclude-azure-powershell-credential: true
exclude-azure-developer-cli-credential: true
exclude-interactive-browser-credential: true
- &azure-verify
name: Check the signatures
if: steps.credentials.outputs.available == 'true'
shell: pwsh
run: .github/release/verify-authenticode.ps1 -Folders "$env:RUNNER_TEMP/work"
- id: upload
if: steps.credentials.outputs.available == 'true'
uses: ./.github/release/upload
with:
name: sign-windows
path: ${{ runner.temp }}/work
# Setup.exe around the signed executables (unsigned ones when Windows is not
# signed), tested on native x64 and ARM64 runners. Repository code: a build.
installers:
needs: [plan, build, sign-windows]
if: ${{ !cancelled() && needs.build.result == 'success' && needs.sign-windows.result == 'success' }}
uses: ./.github/workflows/windows-installers.yml
with:
sha: ${{ needs.plan.outputs.sha }}
version: ${{ needs.plan.outputs.release-version }}
pattern: ${{ needs.sign-windows.outputs.signed == 'true' && 'sign-windows' || 'build-windows-*' }}
digests: ${{ needs.sign-windows.outputs.signed == 'true' && format('sign-windows={0}', needs.sign-windows.outputs.digest) || format('build-windows-x86_64={0} build-windows-aarch64={1}', needs.build.outputs.windows-x64-digest, needs.build.outputs.windows-arm64-digest) }}
artifact-name: build-windows-installers
sign-windows-installers:
needs: [plan, sign-windows, installers]
if: ${{ !cancelled() && needs.installers.result == 'success' && needs.sign-windows.outputs.signed == 'true' }}
runs-on: windows-latest
timeout-minutes: 30
environment: release
permissions:
contents: read
id-token: write
env: *windows-sign-env
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- *checkout-release
- *azure-credentials
- name: Download
uses: ./.github/release/download
with:
pattern: build-windows-installers
digests: build-windows-installers=${{ needs.installers.outputs.digest }}
- name: Gather the installers
run: |
temp=$(cygpath -u "$RUNNER_TEMP")
mkdir -p "$temp/work" && cp "$temp"/in/build-windows-installers/*.exe "$temp/work/"
- *azure-login
- *azure-sign
- *azure-verify
- id: upload
uses: ./.github/release/upload
with:
name: sign-windows-installers
path: ${{ runner.temp }}/work
# ---- Verify: repository code on the signed files; no secrets ----------------
# What a user's Mac and the in-app updater check, and a launch.
verify-macos:
needs: [plan, sign-macos]
if: ${{ !cancelled() && needs.sign-macos.result == 'success' && needs.sign-macos.outputs.signed == 'true' }}
runs-on: macos-26
timeout-minutes: 30
env:
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- uses: ./.github/release/download
with:
pattern: sign-macos
digests: sign-macos=${{ needs.sign-macos.outputs.digest }}
- name: Check the signed app and DMG
run: |
dmg="$RUNNER_TEMP/in/sign-macos/hex-$HEX_VERSION-macos-arm64.dmg"
zip="$RUNNER_TEMP/in/sign-macos/hex-$HEX_VERSION-macos-arm64.zip"
xcrun stapler validate "$dmg"
spctl --assess --type open --context context:primary-signature --verbose=2 "$dmg"
check=$(mktemp -d)
hdiutil attach -quiet -nobrowse -readonly -mountpoint "$check/dmg" "$dmg"
/usr/bin/ditto -x -k "$zip" "$check/update"
build=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$check/dmg/Hex.app/Contents/Info.plist")
scripts/validate-app.sh "$check/dmg/Hex.app" Hex.app "$HEX_VERSION" "$build"
scripts/validate-app.sh "$check/update/Hex.app" Hex.app "$HEX_VERSION" "$build"
xcrun stapler validate "$check/update/Hex.app"
# What the in-app updater requires before it swaps the bundle in.
codesign --verify --deep --strict -R="$(cat app/update-requirement.txt)" "$check/update/Hex.app"
spctl --assess --type execute --verbose=2 "$check/dmg/Hex.app"
diff -qr "$check/dmg/Hex.app" "$check/update/Hex.app"
scripts/smoke-macos-app.sh "$check/dmg/Hex.app"
hdiutil detach -quiet "$check/dmg"
codesign -dv "$check/update/Hex.app" 2>&1 | grep -E '^(Identifier|TeamIdentifier|Authority=Developer)' >> "$GITHUB_STEP_SUMMARY"
# ---- Publish: release environment; only .github/release/ is checked out ----
# The only job that publishes to the release service; its OIDC token is the
# credential. Publishes every signed platform (stable requires them all).
publish:
needs: [plan, build, sign-macos, verify-macos, sign-windows, installers, sign-windows-installers]
if: >-
${{ !cancelled() && needs.plan.outputs.channel != 'check'
&& needs.build.result == 'success' && needs.installers.result == 'success'
&& needs.sign-windows.result == 'success'
&& (needs.plan.outputs.channel == 'dev'
|| (needs.sign-macos.result == 'success'
&& (needs.verify-macos.result == 'success' || needs.sign-macos.outputs.signed != 'true')))
&& (needs.sign-windows-installers.result == 'success' || needs.sign-windows.outputs.signed != 'true') }}
runs-on: ubuntu-24.04
environment: release
permissions:
contents: read
id-token: write
env: &publish-env
RELEASE: ${{ needs.plan.outputs.service }}
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
HEX_RELEASE_CHANNEL: ${{ needs.plan.outputs.release-channel }}
outputs:
linux-x64-url: ${{ steps.publish.outputs.linux-x64-url }}
linux-arm64-url: ${{ steps.publish.outputs.linux-arm64-url }}
steps:
- *checkout-release
- name: Download
uses: ./.github/release/download
with:
# A dev release goes out without macOS when its signing or
# verification fails (the run still fails, so it is seen); only a
# verified macOS build is ever published.
pattern: ${{ (needs.sign-macos.result == 'success' && needs.verify-macos.result == 'success') && '{build-linux-*,sign-macos,sign-windows,sign-windows-installers}' || '{build-linux-*,sign-windows,sign-windows-installers}' }}
digests: >-
build-linux-x86_64=${{ needs.build.outputs.linux-x64-digest }}
build-linux-aarch64=${{ needs.build.outputs.linux-arm64-digest }}
sign-macos=${{ needs.sign-macos.outputs.digest }}
sign-windows=${{ needs.sign-windows.outputs.digest }}
sign-windows-installers=${{ needs.sign-windows-installers.outputs.digest }}
- name: Gather the release files
run: bash .github/release/assemble.sh "$RUNNER_TEMP/in" "$RUNNER_TEMP/dist"
- name: Sign the Linux executables
env:
HEX_RELEASE_SIGNING_KEY: ${{ secrets.HEX_RELEASE_SIGNING_KEY }}
run: bash .github/release/sign-linux.sh "$RUNNER_TEMP/dist"
- id: publish
name: Publish
env:
NOTES_URL: ${{ needs.plan.outputs.notes-url }}
run: |
bash .github/release/release-service.sh publish "$RUNNER_TEMP/dist" "$NOTES_URL"
for target in linux-x64 linux-arm64; do
echo "$target-url=${RELEASE%/release}$(jq -r --arg target "$target" '.release.targets[$target].url' "$RUNNER_TEMP/dist/manifest.json")" >> "$GITHUB_OUTPUT"
done
{ echo '### Manifest'; echo '```json'; cat "$RUNNER_TEMP/dist/manifest.json"; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
- name: Record the Nix flake and the Linux packages
# The flake builds this commit from source, and the .deb and .rpm are
# files of this release, so they serve the version now.
if: needs.plan.outputs.channel == 'stable'
run: |
for kind in nix deb-x64 deb-arm64 rpm-x64 rpm-arm64; do
bash .github/release/release-service.sh distribution "$kind" "$HEX_VERSION"
done
# Last, once every platform and the release service published: tags
# v<version> on the released commit and mirrors the files to its GitHub
# release, with the built-in token; a failed run leaves no tag. Tags trigger
# nothing. A check run pushes and deletes a throwaway v0.0.0-test-<run> tag
# to prove the token can tag.
github:
name: Tag and GitHub release
needs: [plan, build, publish, sign-macos, verify-macos, sign-windows, installers, sign-windows-installers]
if: >-
${{ !cancelled() && (
(needs.plan.outputs.channel == 'stable' && needs.publish.result == 'success')
|| (needs.plan.outputs.channel == 'check' && needs.installers.result == 'success'
&& (needs.verify-macos.result == 'success' || needs.sign-macos.outputs.signed != 'true')) ) }}
runs-on: ubuntu-24.04
permissions:
contents: write
env:
SHA: ${{ needs.plan.outputs.sha }}
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
HEX_RELEASE_COMMIT: ${{ needs.plan.outputs.sha }}
HEX_RELEASE_TAG: ${{ needs.plan.outputs.tag }}
HEX_RELEASE_SOURCE: ${{ github.workspace }}
steps:
# Credentials stay so the job can push the tag; it runs no repository
# code beyond .github/release/.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
sparse-checkout: |
/.github/release/
/docs/releases/
sparse-checkout-cone-mode: false
- name: Tag
env:
HEX_RELEASE_TAG_TEST: ${{ needs.plan.outputs.channel == 'check' && '1' || '' }}
run: bash .github/release/tag-release.sh
- name: Download
if: needs.plan.outputs.channel == 'stable'
uses: ./.github/release/download
with:
pattern: "{build-linux-*,sign-macos,sign-windows,sign-windows-installers}"
digests: >-
build-linux-x86_64=${{ needs.build.outputs.linux-x64-digest }}
build-linux-aarch64=${{ needs.build.outputs.linux-arm64-digest }}
sign-macos=${{ needs.sign-macos.outputs.digest }}
sign-windows=${{ needs.sign-windows.outputs.digest }}
sign-windows-installers=${{ needs.sign-windows-installers.outputs.digest }}
- name: Gather the release files
if: needs.plan.outputs.channel == 'stable'
run: bash .github/release/assemble.sh "$RUNNER_TEMP/in" "$RUNNER_TEMP/dist"
- name: GitHub release
if: needs.plan.outputs.channel == 'stable'
env:
GH_TOKEN: ${{ github.token }}
run: bash .github/release/publish-github-release.sh "$RUNNER_TEMP/dist"
# Builds and installs hex-bin from the published x64 file, without
# secrets; its PKGBUILD also names the published arm64 file.
aur-stage:
name: AUR package
needs: [plan, build, publish]
if: ${{ !cancelled() && needs.publish.result == 'success' && needs.plan.outputs.channel == 'stable' }}
runs-on: ubuntu-24.04
container: archlinux:base-devel
env:
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
LINUX_X64_URL: ${{ needs.publish.outputs.linux-x64-url }}
LINUX_ARM64_URL: ${{ needs.publish.outputs.linux-arm64-url }}
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- name: Install tools
run: |
pacman -Syu --noconfirm --needed git
useradd --create-home builder
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- uses: ./.github/release/download
with:
pattern: build-linux-*
digests: >-
build-linux-x86_64=${{ needs.build.outputs.linux-x64-digest }}
build-linux-aarch64=${{ needs.build.outputs.linux-arm64-digest }}
- name: Stage and test hex-bin
run: |
x64="$RUNNER_TEMP/in/build-linux-x86_64/hex-$HEX_VERSION-linux-x64"
arm64="$RUNNER_TEMP/in/build-linux-aarch64/hex-$HEX_VERSION-linux-arm64"
# makepkg refuses root, so builder stages and builds in its own home from
# copies; the runner's files in the workspace and RUNNER_TEMP keep their owner.
src=/home/builder/src
stage=/home/builder/aur
mkdir "$src"
cp -R scripts packaging LICENSE "$x64" "$arm64" "$src/"
chown -R builder: "$src"
runuser -u builder -- "$src/scripts/release-aur.sh" stage "$HEX_VERSION" \
"$src/${x64##*/}" "$LINUX_X64_URL" "$src/${arm64##*/}" "$LINUX_ARM64_URL" "$stage"
runuser -u builder -- "$src/scripts/release-aur.sh" test "$stage"
pacman -U --noconfirm "$stage"/hex-bin-*.pkg.tar.zst
test "$(hex --version | awk 'NF { value=$NF } END { print value }')" = "$HEX_VERSION"
# The PKGBUILD's sources are the published files.
curl -fsS "$LINUX_X64_URL" | cmp - "$x64"
curl -fsS "$LINUX_ARM64_URL" | cmp - "$arm64"
mkdir -p "$RUNNER_TEMP/aur-out"
(cd "$stage" && cp PKGBUILD .SRCINFO anomaly.hex.desktop hex.service LICENSE hex-bin.install anomaly.hex-*.png "$RUNNER_TEMP/aur-out/")
{ echo '### AUR PKGBUILD'; echo '```'; cat "$stage/PKGBUILD"; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
- id: upload
uses: ./.github/release/upload
with:
name: build-aur
path: ${{ runner.temp }}/aur-out
aur:
name: AUR
needs: [plan, aur-stage]
if: ${{ !cancelled() && needs.aur-stage.result == 'success' }}
runs-on: ubuntu-24.04
environment: release
steps:
- *checkout-release
- uses: ./.github/release/download
with:
pattern: build-aur
digests: build-aur=${{ needs.aur-stage.outputs.digest }}
- name: Push to the AUR
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: bash .github/release/push-aur.sh "$RUNNER_TEMP/in/build-aur"
# Tells AUR installs about the version only once the AUR serves it.
record-aur:
needs: [plan, aur]
if: ${{ !cancelled() && needs.aur.result == 'success' }}
runs-on: ubuntu-24.04
environment: release
permissions:
contents: read
id-token: write
env: *publish-env
steps:
- *checkout-release
- run: bash .github/release/release-service.sh distribution aur "$HEX_VERSION"
# Renders the cask from the published DMG and checks it with brew, without
# secrets.
homebrew-stage:
name: Homebrew cask
needs: [plan, publish]
if: ${{ !cancelled() && needs.publish.result == 'success' && needs.plan.outputs.channel == 'stable' }}
runs-on: macos-15
env:
RELEASE: ${{ needs.plan.outputs.service }}
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
RELEASE_CHANNEL: ${{ needs.plan.outputs.release-channel }}
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Render the cask from the published DMG
run: |
curl -fsS "$RELEASE/hex/desktop/$RELEASE_CHANNEL.json" -o "$RUNNER_TEMP/manifest.json"
version=$(jq -er .release.version "$RUNNER_TEMP/manifest.json")
test "$version" = "$HEX_VERSION"
dmg=$(jq -ec '.release.targets["macos-arm64-dmg"]' "$RUNNER_TEMP/manifest.json") || {
echo "::error::Hex $version has no macos-arm64-dmg build."
exit 1
}
url="${RELEASE%/release}$(printf '%s' "$dmg" | jq -r .url)"
sha256=$(printf '%s' "$dmg" | jq -r .sha256)
mkdir -p "$RUNNER_TEMP/cask"
scripts/release-homebrew.sh render "$version" "$url" "$sha256" "$RUNNER_TEMP/cask/hex.rb"
{ echo '### Casks/hex.rb'; echo '```ruby'; cat "$RUNNER_TEMP/cask/hex.rb"; echo '```'; } >> "$GITHUB_STEP_SUMMARY"
- name: Check it with brew
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_FROM_API: "1"
run: |
brew tap anomalyco/tap
cp "$RUNNER_TEMP/cask/hex.rb" "$(brew --repo anomalyco/tap)/Casks/hex.rb"
# Homebrew 6 refuses to load casks from third-party taps until they
# are trusted; this runner trusts our own tap. Older Homebrew has no
# `brew trust` and no such check.
if brew trust --help > /dev/null 2>&1; then brew trust anomalyco/tap; fi
brew style --cask anomalyco/tap/hex
brew audit --cask --strict --online anomalyco/tap/hex
- id: upload
uses: ./.github/release/upload
with:
name: build-homebrew
path: ${{ runner.temp }}/cask
homebrew:
name: Homebrew
needs: [plan, homebrew-stage]
if: ${{ !cancelled() && needs.homebrew-stage.result == 'success' }}
runs-on: ubuntu-24.04
environment: release
env:
HEX_VERSION: ${{ needs.plan.outputs.release-version }}
steps:
- *checkout-release
- uses: ./.github/release/download
with:
pattern: build-homebrew
digests: build-homebrew=${{ needs.homebrew-stage.outputs.digest }}
- name: Push to anomalyco/homebrew-tap
env:
HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
run: bash .github/release/push-homebrew.sh "$RUNNER_TEMP/in/build-homebrew/hex.rb" "$HEX_VERSION"
# Tells Homebrew installs about the version only once the tap serves it.
record-brew:
needs: [plan, homebrew]
if: ${{ !cancelled() && needs.homebrew.result == 'success' }}
runs-on: ubuntu-24.04
environment: release
permissions:
contents: read
id-token: write
env: *publish-env
steps:
- *checkout-release
- run: bash .github/release/release-service.sh distribution brew "$HEX_VERSION"