Repository navigation
1337 lines (1206 loc) · 55 KB
/
Copy pathrelease.yml
File metadata and controls
1337 lines (1206 loc) · 55 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
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Release
env:
JCODE_CI: "1"
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
RELEASE_REPAIR: ${{ inputs.recovery || 'none' }}
# Dry runs build and package every platform from an existing tag but never
# create, upload to, edit, or publish a release.
DRY_RUN: ${{ inputs.dry_run && 'true' || 'false' }}
RELEASE_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
# CI builds without the local parallel-frontend rustc wrapper from
# .cargo/config.toml (a POSIX shell script; see scripts/rustc-parallel-frontend).
CARGO_BUILD_RUSTC_WRAPPER: ""
CARGO_TERM_COLOR: always
SCCACHE_GHA_ENABLED: "true"
CARGO_INCREMENTAL: "0"
# Optimize published binaries fully without changing local/selfdev profiles.
CARGO_PROFILE_RELEASE_OPT_LEVEL: "3"
# Preserve stable/nightly selected below rather than adopting a JR toolchain.
JUSTRUST_TOOLCHAIN: system
# Keep packaging paths deterministic and CI installation noninteractive.
JUSTRUST_SLOTS: "0"
JUSTRUST_NO_TELEMETRY: "1"
on:
workflow_dispatch:
inputs:
tag:
description: Existing release tag (vMAJOR.MINOR.PATCH)
required: true
type: string
recovery:
description: Reviewed source repair (only v0.96.0 or v0.97.0)
type: choice
default: none
options: [none, windows-listener]
dry_run:
description: Build and package every platform without touching the release
type: boolean
default: false
push:
tags:
- 'v*'
- '!v*-preview.*'
concurrency:
group: release-${{ inputs.tag || github.ref_name }}${{ inputs.dry_run && '-dry-run' || '' }}
cancel-in-progress: false
permissions:
actions: read
contents: write
jobs:
create-release:
name: Create release
# Publish only from the canonical repository. A fork that runs this
# workflow on a `v*` tag would otherwise create a release carrying that
# upstream version number with binaries built from the fork, which is the
# same class of accidental-publication path as a fork pushing a package.
# Every other job in this workflow needs `create-release`, directly or
# transitively, so gating this one job skips the whole workflow: a skipped
# dependency skips its dependents. Preview tags are excluded at the trigger
# and here as defense in depth, including manual dispatch.
if: github.repository == '1jehuang/jcode' && !contains(inputs.tag || github.ref_name, '-preview.')
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
tag_sha: ${{ steps.source.outputs.tag_sha }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate release source
id: source
shell: bash
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_REF: ${{ github.ref }}
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
[[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Invalid release tag" >&2; exit 1; }
if [ "$EVENT_NAME" = workflow_dispatch ] && [ "$WORKFLOW_REF" != refs/heads/master ]; then
echo "Recovery must use the reviewed workflow on master" >&2; exit 1
fi
tag_sha=$(git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}")
if [ "$EVENT_NAME" = push ] && [ "$tag_sha" != "$WORKFLOW_SHA" ]; then
echo "Release tag no longer matches the triggering commit" >&2; exit 1
fi
echo "tag_sha=$tag_sha" >> "$GITHUB_OUTPUT"
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
git checkout --detach "$tag_sha"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
if [ "$EVENT_NAME" = workflow_dispatch ] && [ "$DRY_RUN" != true ]; then
python3 "$RUNNER_TEMP/recovery.py" --check-public-state "$RELEASE_TAG"
fi
- uses: dtolnay/rust-toolchain@stable
- name: Verify frozen dependency resolution
shell: bash
run: |
cargo metadata --locked --format-version 1 > "$RUNNER_TEMP/release-cargo-metadata.json"
git diff --exit-code -- Cargo.lock
# Render a human-readable changelog for the release body (issue #435):
# changelog/v<version>.json when present, otherwise grouped commit
# subjects since the previous tag, always ending with the compare link.
- name: Generate release notes
shell: bash
run: |
scripts/generate_release_notes.sh "$RELEASE_TAG" > release_notes.md
if [ "$RELEASE_REPAIR" != none ]; then
# shellcheck disable=SC2016 # Markdown backticks are literal prose.
printf '\n## Release source recovery\n\nBuilt from existing tag `%s` with reviewed `%s` repair from workflow commit `%s`. The tag and version are unchanged. This is patched tag source, not the exact tagged tree. Release-only installer tooling is pinned to the same workflow commit. See `release-provenance.json` for source hashes and build run.\n' "$RELEASE_TAG" "$RELEASE_REPAIR" "$GITHUB_SHA" >> release_notes.md
fi
# Stage platform assets on a draft. The final job publishes every
# successfully completed asset and records unavailable platforms.
- name: Create draft release if missing
if: env.DRY_RUN != 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if ! gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
# quick-release.sh can race this job after pushing the tag. If it
# creates the draft first, verify that release and continue.
if ! gh release create "${RELEASE_TAG}" \
--draft \
--title "${RELEASE_TAG}" \
--notes-file release_notes.md; then
sleep 2
gh release view "${RELEASE_TAG}" >/dev/null
fi
fi
gh release edit "${RELEASE_TAG}" --notes-file release_notes.md
# Exact-commit CI runs concurrently with the platform builds. Builds only
# stage assets on a hidden draft. Publication (the finalize job) requires
# this gate, so overlapping it saves the full CI wall time per release.
ci-gate:
name: Require exact-commit CI
needs: create-release
if: ${{ (inputs.recovery || 'none') == 'none' }}
runs-on: ubuntu-latest
# Exact-commit CI includes a native Windows test job with a 150-minute cap.
timeout-minutes: 190
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Require successful exact-commit CI for unpatched source
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG_SHA: ${{ needs.create-release.outputs.tag_sha }}
run: |
set -euo pipefail
python3 scripts/check_release_ci.py "$TAG_SHA" --repo "$GITHUB_REPOSITORY" --timeout 10800
recovery-preflight:
name: Recovery companion preflight (${{ matrix.target }})
needs: create-release
if: github.event_name == 'workflow_dispatch' && inputs.recovery == 'windows-listener'
runs-on: ${{ matrix.os }}
timeout-minutes: 35
env:
JUSTRUST_DISABLE: "1"
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
arch: amd64
- os: windows-11-arm
target: aarch64-pc-windows-msvc
arch: amd64_arm64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: recovery-companion-${{ matrix.target }}
- name: Install pinned justrust
shell: bash
run: bash scripts/install_justrust_ci.sh
- name: Check and test exact repaired companion source
shell: pwsh
run: |
& justrust check --local --locked -p jcode-companion --target ${{ matrix.target }}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& justrust test --local --locked -p jcode-companion --lib --target ${{ matrix.target }}
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Verify preflight preserved Cargo.lock
shell: bash
run: git diff --exit-code -- Cargo.lock
build-linux-macos:
# Job id kept for history. Linux moved to build-linux-hosted.
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [create-release, recovery-preflight]
if: ${{ always() && needs.create-release.result == 'success' && (needs.recovery-preflight.result == 'success' || needs.recovery-preflight.result == 'skipped') }}
# Each matrix architecture is independent. A failed Linux or macOS target
# must not suppress assets produced by the other successful targets.
continue-on-error: true
# Native Intel macOS took 59-68 min at optimization level 3, so it is now
# cross-compiled on the faster Apple Silicon runner. Keep headroom for
# healthy cold-cache builds without changing any acceptance checks.
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
# Linux builds run on justrust hosted (build-linux-hosted below).
- os: macos-latest
target: aarch64-apple-darwin
artifact: jcode-macos-aarch64
- # Cross-compile on Apple Silicon: the Intel runner is roughly 2x
# slower and was the release critical path. Apple's toolchain
# targets x86_64 natively, so the output matches a native build.
os: macos-latest
target: x86_64-apple-darwin
artifact: jcode-macos-x86_64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
submodules: recursive
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- name: Configure SSH for cargo git dependencies
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7
continue-on-error: true
id: sccache
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-all-crates: "true"
- name: Install pinned justrust
shell: bash
run: bash scripts/install_justrust_ci.sh
# Native macOS hosted routing is not enabled. Keep the runner toolchain.
- name: Build release binary
shell: bash
run: |
if command -v sccache &>/dev/null && sccache --start-server 2>/dev/null; then
export RUSTC_WRAPPER=sccache
fi
justrust build --local --locked --release --target ${{ matrix.target }}
env:
JCODE_RELEASE_BUILD: "1"
JCODE_CI_BUILD: "1"
JCODE_BUILD_SEMVER: ${{ env.RELEASE_TAG }}
- name: Verify release build preserved Cargo.lock
shell: bash
run: git diff --exit-code -- Cargo.lock
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/jcode dist/${{ matrix.artifact }}
chmod +x dist/${{ matrix.artifact }}
if [ "$RUNNER_OS" = "macOS" ]; then
# The linker's ad-hoc signature uses cargo's hashed output name
# (`jcode-<hash>`) as the code-signing identifier, so every release
# looked like a different program. macOS Tahoe's "Allow in the Menu
# Bar" keys unbundled executables on that identity, which added a new
# jcode toggle per update and reset the menu bar item's placement
# (#621). Re-sign ad-hoc with a stable identifier.
codesign --force --sign - --identifier com.jcode.cli dist/${{ matrix.artifact }}
codesign -dv dist/${{ matrix.artifact }} 2>&1 | grep -qx 'Identifier=com.jcode.cli'
fi
cd dist && tar czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}.tar.gz
# Attach this platform's asset to the draft release. It remains hidden
# until the final job verifies the complete release set.
- name: Publish asset to release
if: env.DRY_RUN != 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${RELEASE_TAG}" "dist/${{ matrix.artifact }}.tar.gz" --clobber
bash scripts/release_refresh_checksums.sh "${RELEASE_TAG}"
# Linux compiles on justrust hosted at full optimization (opt-level 3):
# x86_64 via zig for the glibc 2.17 baseline, ARM64 with emulated TLS. The
# same scripts ship v1 previews. Hosted builds take about 5 minutes, versus
# 15-54 minutes on GitHub runners. Runtime acceptance stays on GitHub: the
# x86_64 binary must run inside the glibc 2.17 baseline container, and the
# ARM64 archive must run on a native ARM runner before it is published.
build-linux-hosted:
name: Build hosted (${{ matrix.target }})
runs-on: ubuntu-24.04
needs: [create-release, recovery-preflight]
if: ${{ always() && needs.create-release.result == 'success' && (needs.recovery-preflight.result == 'success' || needs.recovery-preflight.result == 'skipped') }}
continue-on-error: true
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
artifact: jcode-linux-x86_64
- target: aarch64-unknown-linux-gnu
artifact: jcode-linux-aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
submodules: recursive
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.99.0
- name: Install source-pinned hosted justrust
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
run: |
set -euo pipefail
# Build tooling comes from the workflow commit so older tags build
# with the current hosted contract. The tag supplies the sources.
for f in install_justrust_hosted_ci.sh build_preview_linux_hosted.sh package_preview_linux_hosted.sh; do
git show "$WORKFLOW_SHA:scripts/$f" > "scripts/$f"
done
bash scripts/install_justrust_hosted_ci.sh
- name: Build on justrust hosted
shell: bash
env:
JCODE_API_KEY: ${{ secrets.JUSTRUST_API_KEY }}
JCODE_BUILD_SEMVER: ${{ env.RELEASE_TAG }}
run: |
set -euo pipefail
test -n "$JCODE_API_KEY" || { echo 'JUSTRUST_API_KEY is required for hosted Linux builds' >&2; exit 1; }
bash scripts/build_preview_linux_hosted.sh "${{ matrix.target }}"
- name: Verify release build preserved Cargo.lock
shell: bash
run: git diff --exit-code -- Cargo.lock
- name: Accept and package portable x86_64 in the glibc 2.17 baseline
if: matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
set -euo pipefail
bash scripts/package_preview_linux_hosted.sh
dist/jcode-linux-x86_64 --no-update --no-selfdev --version | tee "$RUNNER_TEMP/version.txt"
grep -F "jcode ${RELEASE_TAG} " "$RUNNER_TEMP/version.txt"
- name: Package ARM64 (runtime acceptance runs on native ARM)
if: matrix.target == 'aarch64-unknown-linux-gnu'
shell: bash
run: |
set -euo pipefail
mkdir -p dist
cp target/aarch64-unknown-linux-gnu/release/jcode dist/jcode-linux-aarch64
chmod 755 dist/jcode-linux-aarch64
tar czf dist/jcode-linux-aarch64.tar.gz -C dist jcode-linux-aarch64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}.tar.gz
if-no-files-found: error
- name: Publish asset to release
if: env.DRY_RUN != 'true' && matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${RELEASE_TAG}" "dist/${{ matrix.artifact }}.tar.gz" --clobber
bash scripts/release_refresh_checksums.sh "${RELEASE_TAG}"
linux-arm-runtime:
name: Native ARM64 runtime acceptance
needs: [create-release, build-linux-hosted]
if: ${{ always() && needs.create-release.result == 'success' }}
continue-on-error: true
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
# Consume the exact hosted upload. No hosted credentials enter this job.
- uses: actions/download-artifact@v4
with:
name: jcode-linux-aarch64
path: dist
- name: Verify uploaded ARM archive on native Ubuntu 24.04
shell: bash
env:
JCODE_BUILD_SEMVER: ${{ env.RELEASE_TAG }}
run: python3 scripts/verify_preview_arm_runtime.py dist/jcode-linux-aarch64.tar.gz
- name: Publish asset to release
if: env.DRY_RUN != 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${RELEASE_TAG}" dist/jcode-linux-aarch64.tar.gz --clobber
bash scripts/release_refresh_checksums.sh "${RELEASE_TAG}"
build-windows:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: [create-release, recovery-preflight]
if: ${{ always() && needs.create-release.result == 'success' && (needs.recovery-preflight.result == 'success' || needs.recovery-preflight.result == 'skipped') }}
env:
# Pinned alpha.17 measurement crashed on Windows x64 requesting 30 GiB.
# Disable measurement only: the CLI still executes local Cargo and returns
# its exit status. Native Windows hosted routing is unsupported. All
# compile, launch, installer, signing and publication gates remain active.
JUSTRUST_DISABLE: "1"
# Both Windows architectures are required by the final complete-asset gate.
# A compile failure must stop signing rather than cascading into missing files.
# Windows x64 release smoke tests compile the e2e harness after the release
# binary. GitHub-hosted Windows runners sometimes exceed 25 minutes, which
# cancels otherwise healthy releases before artifacts can be uploaded.
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: jcode-windows-x86_64
unsigned_artifact: windows-unsigned-x86_64
- os: windows-11-arm
target: aarch64-pc-windows-msvc
artifact: jcode-windows-aarch64
unsigned_artifact: windows-unsigned-aarch64
cargo_args: "--no-default-features --features pdf"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- name: Configure MSVC build environment (x64)
if: matrix.target == 'x86_64-pc-windows-msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Configure MSVC build environment (ARM64)
if: matrix.target == 'aarch64-pc-windows-msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_arm64
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.7
continue-on-error: true
id: sccache
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
cache-all-crates: "true"
- name: Install pinned justrust
shell: bash
run: bash scripts/install_justrust_ci.sh
# Native Windows hosted routing is not enabled. Preserve the MSVC runner.
- name: Build release binary
shell: pwsh
run: |
if (Get-Command sccache -ErrorAction SilentlyContinue) {
sccache --start-server *> $null
if ($LASTEXITCODE -eq 0) {
$env:RUSTC_WRAPPER = "sccache"
}
}
$cargoArgs = @("build", "--local", "--locked", "--release", "--target", "${{ matrix.target }}")
$extraArgs = "${{ matrix.cargo_args }}"
if (-not [string]::IsNullOrWhiteSpace($extraArgs)) {
$cargoArgs += $extraArgs -split ' '
}
& justrust @cargoArgs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
env:
JCODE_RELEASE_BUILD: "1"
JCODE_CI_BUILD: "1"
JCODE_BUILD_SEMVER: ${{ env.RELEASE_TAG }}
- name: Verify release build preserved Cargo.lock
shell: bash
run: git diff --exit-code -- Cargo.lock
- name: Verify built Windows binary launches
shell: pwsh
run: |
& "target/${{ matrix.target }}/release/jcode.exe" --version
if ($LASTEXITCODE -ne 0) {
throw "Built Windows binary failed to run --version"
}
- name: Verify Windows installer with local artifact
shell: pwsh
run: |
& ./.github/scripts/verify_windows_install.ps1 `
-ArtifactExePath "target/${{ matrix.target }}/release/jcode.exe" `
-Version "${{ env.RELEASE_TAG }}"
- name: Stage unsigned binary for signing
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item "target/${{ matrix.target }}/release/jcode.exe" "dist/${{ matrix.artifact }}.exe"
- name: Upload unsigned binary for signing
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.unsigned_artifact }}
path: dist/${{ matrix.artifact }}.exe
# These debug-harness tests provide extra signal, but they must not block
# publishing a release binary that already built, launched, and passed the
# installer verification. A transient server-test disconnect caused the
# Windows x64 asset to disappear from releases v0.44.0-v0.46.0 (#480).
- name: Run advisory Windows runtime smoke tests (x64)
if: matrix.target == 'x86_64-pc-windows-msvc'
continue-on-error: true
shell: pwsh
run: |
$tests = @(
'provider_behavior::test_socket_model_cycle_supported_models',
'provider_behavior::test_model_switch_resets_provider_session'
)
foreach ($testName in $tests) {
& cargo test --locked --target ${{ matrix.target }} --test e2e $testName -- --exact --nocapture
if ($LASTEXITCODE -ne 0) {
throw "Windows smoke test failed: $testName"
}
}
publish-windows:
name: Sign and publish Windows assets
runs-on: windows-latest
needs: [create-release, build-windows]
# Signing failures keep the complete release draft, including recovery runs.
# The optional recovery-preflight ancestor is skipped for normal releases.
# Override implicit success() so that skip does not suppress signing, while
# still requiring both direct dependencies to succeed.
if: always() && needs.create-release.result == 'success' && needs.build-windows.result == 'success'
timeout-minutes: 30
outputs:
signing_enabled: ${{ steps.signing.outputs.enabled }}
permissions:
contents: write
id-token: write
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
WINDOWS_SIGNING_ENDPOINT: ${{ vars.WINDOWS_SIGNING_ENDPOINT }}
WINDOWS_SIGNING_ACCOUNT: ${{ vars.WINDOWS_SIGNING_ACCOUNT }}
WINDOWS_SIGNING_CERTIFICATE_PROFILE: ${{ vars.WINDOWS_SIGNING_CERTIFICATE_PROFILE }}
WINDOWS_SIGNING_REQUIRED: ${{ vars.WINDOWS_SIGNING_REQUIRED }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- name: Download unsigned Windows binaries
uses: actions/download-artifact@v4
with:
pattern: windows-unsigned-*
path: artifacts
- name: Determine signing mode
id: signing
shell: pwsh
run: |
$requiredValues = @(
$env:AZURE_CLIENT_ID,
$env:AZURE_TENANT_ID,
$env:AZURE_SUBSCRIPTION_ID,
$env:WINDOWS_SIGNING_ENDPOINT,
$env:WINDOWS_SIGNING_ACCOUNT,
$env:WINDOWS_SIGNING_CERTIFICATE_PROFILE
)
$configured = -not ($requiredValues | Where-Object { [string]::IsNullOrWhiteSpace($_) })
"enabled=$($configured.ToString().ToLowerInvariant())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$signingRequired = $env:WINDOWS_SIGNING_REQUIRED -ne 'false'
if (-not $configured -and $signingRequired) {
throw 'Windows signing is required, but Azure Artifact Signing configuration is incomplete. See docs/WINDOWS.md.'
}
if (-not $configured) {
Write-Warning 'Publishing unsigned Windows assets because WINDOWS_SIGNING_REQUIRED=false. This override is not suitable for an official Windows release.'
}
- name: Azure login with GitHub OIDC
if: steps.signing.outputs.enabled == 'true'
uses: azure/login@v3
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Authenticode-sign Windows binaries
if: steps.signing.outputs.enabled == 'true'
uses: azure/artifact-signing-action@v2
with:
endpoint: ${{ vars.WINDOWS_SIGNING_ENDPOINT }}
signing-account-name: ${{ vars.WINDOWS_SIGNING_ACCOUNT }}
certificate-profile-name: ${{ vars.WINDOWS_SIGNING_CERTIFICATE_PROFILE }}
files: |
${{ github.workspace }}\artifacts\windows-unsigned-x86_64\jcode-windows-x86_64.exe
${{ github.workspace }}\artifacts\windows-unsigned-aarch64\jcode-windows-aarch64.exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Verify signatures and package Windows assets
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
$assets = @(
@{ Name = 'jcode-windows-x86_64'; Path = 'artifacts/windows-unsigned-x86_64/jcode-windows-x86_64.exe' },
@{ Name = 'jcode-windows-aarch64'; Path = 'artifacts/windows-unsigned-aarch64/jcode-windows-aarch64.exe' }
)
foreach ($asset in $assets) {
$source = (Resolve-Path -LiteralPath $asset.Path).Path
if ('${{ steps.signing.outputs.enabled }}' -eq 'true') {
$signature = Get-AuthenticodeSignature -LiteralPath $source
if ($signature.Status -ne 'Valid') {
throw "Authenticode verification failed for $($asset.Name): $($signature.Status) $($signature.StatusMessage)"
}
Write-Host "Signed by: $($signature.SignerCertificate.Subject)"
}
$destination = Join-Path dist "$($asset.Name).exe"
Copy-Item -LiteralPath $source -Destination $destination -Force
tar -czf "dist/$($asset.Name).tar.gz" -C dist "$($asset.Name).exe"
}
- name: Upload final Windows artifacts
uses: actions/upload-artifact@v4
with:
name: jcode-windows-x86_64
path: |
dist/jcode-windows-x86_64.exe
dist/jcode-windows-x86_64.tar.gz
- name: Upload final Windows ARM64 artifacts
uses: actions/upload-artifact@v4
with:
name: jcode-windows-aarch64
path: |
dist/jcode-windows-aarch64.exe
dist/jcode-windows-aarch64.tar.gz
- name: Publish Windows assets to release
if: env.DRY_RUN != 'true'
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
gh release upload "${env:RELEASE_TAG}" dist/jcode-windows-x86_64.exe dist/jcode-windows-x86_64.tar.gz dist/jcode-windows-aarch64.exe dist/jcode-windows-aarch64.tar.gz --clobber
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& bash scripts/release_refresh_checksums.sh "${env:RELEASE_TAG}"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
build-freebsd:
name: Build (x86_64-unknown-freebsd)
runs-on: ubuntu-latest
needs: [create-release, recovery-preflight]
if: ${{ always() && needs.create-release.result == 'success' && (needs.recovery-preflight.result == 'success' || needs.recovery-preflight.result == 'skipped') }}
# GitHub has no native FreeBSD runners, so build inside a FreeBSD VM
# (QEMU via vmactions), same approach as freebsd-smoke.yml (issues #416,
# #433). Best-effort: a flaky VM build must not block the rest of the
# release, so failures are surfaced but non-fatal.
continue-on-error: true
timeout-minutes: 180
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- name: Build release binary in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
release: "15.1"
usesh: true
# Give the build VM enough room: aws-lc-sys + tract pull in heavy C/Rust.
mem: 6144
cpu: 4
# The project is OpenSSL-free (rustls + aws-lc-rs): only a C/C++
# toolchain, cmake, and rust are needed.
prepare: |
pkg install -y rust cmake gmake pkgconf bash git
run: |
set -e
echo "::group::Toolchain versions"
uname -a
cc --version | head -1
cargo --version
rustc --version
echo "::endgroup::"
export CARGO_TERM_COLOR=always
# The VM does not inherit the runner's workflow environment.
export CARGO_PROFILE_RELEASE_OPT_LEVEL="${{ env.CARGO_PROFILE_RELEASE_OPT_LEVEL }}"
# CARGO_BUILD_JOBS keeps memory in check; aws-lc-sys is memory hungry.
export CARGO_BUILD_JOBS=3
export JCODE_RELEASE_BUILD=1
export JCODE_CI_BUILD=1
export JCODE_BUILD_SEMVER="${{ env.RELEASE_TAG }}"
# VM source sync omits .git. Keep the baseline outside the source tree.
lock_snapshot=$(mktemp /tmp/jcode-release-Cargo.lock.XXXXXX)
trap 'rm -f "$lock_snapshot"' EXIT
cp Cargo.lock "$lock_snapshot"
echo "::group::cargo build (jcode binary)"
# justrust has no FreeBSD client or hosted worker yet.
cargo build --locked --release -p jcode --bin jcode
cmp "$lock_snapshot" Cargo.lock
echo "::endgroup::"
echo "::group::Verify binary launches"
./target/release/jcode --version
echo "::endgroup::"
mkdir -p dist
cp target/release/jcode dist/jcode-freebsd-x86_64
chmod +x dist/jcode-freebsd-x86_64
cd dist && tar czf jcode-freebsd-x86_64.tar.gz jcode-freebsd-x86_64
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: jcode-freebsd-x86_64
path: dist/jcode-freebsd-x86_64.tar.gz
- name: Publish asset to release
if: env.DRY_RUN != 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${RELEASE_TAG}" "dist/jcode-freebsd-x86_64.tar.gz" --clobber
bash scripts/release_refresh_checksums.sh "${RELEASE_TAG}"
release:
name: Finalize release
# Async publication: FreeBSD is not awaited and attaches its own asset
# (and refreshes SHA256SUMS) after the release is public. Exact-commit CI
# must pass before anything becomes public. The core platforms below must
# exist. Any other platform that failed is published later or not at all,
# and the updater falls back to the newest release carrying its asset.
needs: [create-release, ci-gate, build-linux-hosted, build-linux-macos, publish-windows]
if: ${{ always() && inputs.dry_run != true && needs.create-release.result == 'success' && (needs.ci-gate.result == 'success' || (needs.ci-gate.result == 'skipped' && (inputs.recovery || 'none') != 'none')) }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: write
contents: write
issues: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.tag_sha }}
fetch-depth: 0
- name: Apply reviewed release source recovery
shell: bash
env:
WORKFLOW_SHA: ${{ github.sha }}
RELEASE_PROVENANCE_PATH: ${{ runner.temp }}/release-provenance.json
run: |
set -euo pipefail
git show "$WORKFLOW_SHA:scripts/apply_release_recovery.py" > "$RUNNER_TEMP/recovery.py"
python3 "$RUNNER_TEMP/recovery.py" "$RELEASE_TAG" "$RELEASE_REPAIR" "$WORKFLOW_SHA"
- uses: actions/download-artifact@v4
continue-on-error: true
with:
path: artifacts
pattern: jcode-*
- name: Validate complete platform asset set
shell: bash
run: |
set -euo pipefail
# Core platforms gate publication. Others publish asynchronously.
expected=(
artifacts/jcode-linux-x86_64/jcode-linux-x86_64.tar.gz
artifacts/jcode-macos-aarch64/jcode-macos-aarch64.tar.gz
artifacts/jcode-windows-x86_64/jcode-windows-x86_64.exe
artifacts/jcode-windows-x86_64/jcode-windows-x86_64.tar.gz
)
missing=()
for asset in "${expected[@]}"; do
if [ ! -f "$asset" ]; then
missing+=("$asset")
fi
done
if [ "${#missing[@]}" -ne 0 ]; then
printf 'Missing required release asset: %s\n' "${missing[@]}" >&2
echo "Keeping the release as a draft until every core platform succeeds" >&2
exit 1
fi
# Build jobs normally attach their own assets to the draft. Upload them
# again here so a late per-platform upload failure cannot leave a built
# artifact out of the public release.
- name: Attach all completed platform assets
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mapfile -d '' assets < <(
find artifacts -type f \( -name '*.tar.gz' -o -name '*.exe' \) -print0
)
if [ "${#assets[@]}" -eq 0 ]; then
echo "No completed release assets found" >&2
exit 1
fi
gh release upload "${RELEASE_TAG}" "${assets[@]}" --clobber
- name: Record platform availability
shell: bash
run: |
set -euo pipefail
available() {
if [ -f "$1" ]; then printf true; else printf false; fi
}
linux_x86_64=$(available artifacts/jcode-linux-x86_64/jcode-linux-x86_64.tar.gz)
linux_aarch64=$(available artifacts/jcode-linux-aarch64/jcode-linux-aarch64.tar.gz)
macos_aarch64=$(available artifacts/jcode-macos-aarch64/jcode-macos-aarch64.tar.gz)
macos_x86_64=$(available artifacts/jcode-macos-x86_64/jcode-macos-x86_64.tar.gz)
windows_x86_64=$(available artifacts/jcode-windows-x86_64/jcode-windows-x86_64.exe)
windows_aarch64=$(available artifacts/jcode-windows-aarch64/jcode-windows-aarch64.exe)
freebsd_x86_64=$(available artifacts/jcode-freebsd-x86_64/jcode-freebsd-x86_64.tar.gz)
homebrew_ready=false
aur_ready=false
if [ "$linux_x86_64" = true ] && [ "$linux_aarch64" = true ] && \
[ "$macos_aarch64" = true ] && [ "$macos_x86_64" = true ]; then
homebrew_ready=true
fi
if [ "$linux_x86_64" = true ]; then
aur_ready=true
fi
{
echo "LINUX_X86_64_AVAILABLE=$linux_x86_64"
echo "LINUX_AARCH64_AVAILABLE=$linux_aarch64"
echo "MACOS_AARCH64_AVAILABLE=$macos_aarch64"
echo "MACOS_X86_64_AVAILABLE=$macos_x86_64"
echo "WINDOWS_X86_64_AVAILABLE=$windows_x86_64"
echo "WINDOWS_AARCH64_AVAILABLE=$windows_aarch64"
echo "FREEBSD_X86_64_AVAILABLE=$freebsd_x86_64"
echo "HOMEBREW_READY=$homebrew_ready"
echo "AUR_READY=$aur_ready"
} >> "$GITHUB_ENV"
pending=""
for p in linux-aarch64:$linux_aarch64 macos-x86_64:$macos_x86_64 \
windows-aarch64:$windows_aarch64 freebsd-x86_64:$freebsd_x86_64; do
[ "${p#*:}" = true ] || pending="$pending --allow-missing ${p%%:*}"
done
# FreeBSD is never awaited, so its asset may race finalize.
case "$pending" in *freebsd*) ;; *) pending="$pending --allow-missing freebsd-x86_64" ;; esac
echo "PENDING_PLATFORM_ARGS=$pending" >> "$GITHUB_ENV"
{
echo "## Platform availability"
echo "- Linux x86_64: $linux_x86_64"
echo "- Linux aarch64: $linux_aarch64"
echo "- macOS Apple Silicon: $macos_aarch64"
echo "- macOS Intel: $macos_x86_64"
echo "- Windows x86_64: $windows_x86_64"
echo "- Windows ARM64: $windows_aarch64"
echo "- FreeBSD x86_64: $freebsd_x86_64"
} >> "$GITHUB_STEP_SUMMARY"
# SHA256SUMS covers exactly what is attached right now. Late async