Repository navigation
1412 lines (1318 loc) · 75.3 KB
/
Copy pathrelease.yml
File metadata and controls
1412 lines (1318 loc) · 75.3 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
# ╔══════════════════════════════════════════════════════════════════════════════╗
# ║ BNK-Forge v2 — Release Pipeline ║
# ║ ║
# ║ Triggers: ║
# ║ • push to staging → pre-release RC tag (no VERSION commit) ║
# ║ • push to main → final release (VERSION bump + CHANGELOG commit) ║
# ║ • workflow_dispatch → manual override (keeps the original manual path) ║
# ║ ║
# ║ Version derivation: conventional commits since last final vX.Y.Z tag ║
# ║ feat! / BREAKING CHANGE → major ║
# ║ feat → minor ║
# ║ fix / other → patch ║
# ║ ║
# ║ Loop guard: our automated release commits carry [skip ci] in the SUBJECT, ║
# ║ so GitHub drops their push runs before this workflow even starts. The job ║
# ║ below is a backstop that FAILS the run on any OTHER suppressed commit — a ║
# ║ release that published nothing must never read as green. ║
# ╚══════════════════════════════════════════════════════════════════════════════╝
name: Release
on:
push:
branches:
- staging
- main
# ci.yml has NO push paths-ignore any more: it runs CI on EVERY push to
# main/staging (ci.yml:31-36, #182). That is a strict superset of the pushes
# that reach Release here, so any push that starts a release is guaranteed a
# matching CI run for the preflight SHA poll below to find — regardless of
# what this list ignores. This paths-ignore therefore only spares docs-only
# pushes from kicking off a release at all (PR #297 review; premise updated
# for #182, which removed ci.yml's paths-ignore).
paths-ignore:
- '**.md'
- 'docs/**'
- '.agent/**'
- '.opencode/**'
- 'LICENSE'
- '.gitignore'
- '.trivyignore'
- 'USER_GUIDE.md'
workflow_dispatch:
inputs:
version_bump:
description: "Version bump type"
required: true
default: "patch"
type: choice
options:
- patch # 2.10.49 → 2.10.50
- minor # 2.10.49 → 2.11.0
- major # 2.10.49 → 3.0.0
run_e2e:
description: "Run E2E tests before release"
# Not required: a publish_only recovery run ignores it (it has a default
# and never gates the republish path) — bonnyr-f5 #181 round 2.
required: false
default: true
type: boolean
release_notes:
description: "Release notes (one-line summary). Ignored when publish_only is set."
# Not required for the same reason: publish_only recovery runs ignore it.
required: false
default: ""
type: string
publish_only:
description: "Recovery: republish images for an EXISTING tag (e.g. v4.0.0). Leave empty for a normal release. When set, version_bump / run_e2e / release_notes are ignored."
required: false
type: string
default: ""
force:
description: "Overwrite images that ALREADY exist in the registry for this tag. Off by default: publishing refuses when the :VERSION manifest is already present, so a republish can't silently move an immutable tag and orphan its cosign/SBOM/SLSA attestations. Only a recovery of a tag whose publish never completed needs this off; set it on to deliberately re-push."
required: false
type: boolean
default: false
sign_only:
description: "Recovery for a publish that pushed all images but failed at signing (e.g. cosign/OIDC error AFTER the bake succeeded). Re-runs cosign sign + SBOM + provenance against the ALREADY-pushed :VERSION digests WITHOUT rebuilding or re-pushing — cosign sign is idempotent and the immutable tag never moves. Requires publish_only=<tag>. Use this instead of force=true for a sign-only recovery: force rebuilds all images to possibly-different digests and moves the immutable tag (the exact INV-24 harm the overwrite guard exists to prevent)."
required: false
type: boolean
default: false
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false # Never cancel a release in progress
# Least-privilege default so guard/preflight don't inherit the repo-default
# token scope (bonnyr-f5 #181 round 2). Jobs that need more (contents: write to
# push tags, packages/id-token to publish) declare it themselves below; a job's
# own permissions: block replaces this one rather than merging.
permissions:
contents: read
jobs:
# ── Guard: skip release: commits on main (prevents infinite loop) ────────────
guard:
name: "Loop guard"
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Check head commit
id: check
env:
HEAD_COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
MSG="$HEAD_COMMIT_MSG"
FIRST="${MSG%%$'\n'*}"
# Match the SUBJECT line only. grep is line-oriented, so testing the
# whole message let a [skip ci] line buried in the body — a quoted CI
# snippet, a changelog paste — suppress a legitimate release while the
# message below quoted a subject carrying no marker (bonnyr-f5 #181
# round 2). On a normal push GitHub's own [skip ci] handling already
# drops our release commits (their subject is "release: vX.Y.Z
# [skip ci]") before this workflow starts, and on workflow_dispatch
# head_commit is null so FIRST is empty and nothing matches — this
# guard is a backstop, not the primary suppressor.
if grep -qE '^release: |^\[skip ci\]|\[skip ci\]$' <<< "$FIRST"; then
echo "should_run=false" >> "$GITHUB_OUTPUT"
# Only OUR OWN automated release commit is exempt (a silent, green
# skip). It has a distinguishing fingerprint that a human commit does
# not: the subject is EXACTLY "release: vX.Y.Z [skip ci]" — a version
# AND the skip marker we ourselves append (see the two `git commit`
# calls below). Matching "release:" + a version alone was wrong: a
# hand-written commit like "release: v3.2.0 notes" (a human writing
# release notes, no marker) also matched and was silently skipped
# green, publishing nothing while reporting success — the exact
# silent-green class this guard exists to prevent (bonnyr-f5 #181
# round 4). Requiring the trailing [skip ci] marker restricts the
# exemption to commits we minted.
#
# SINGLE SOURCE (bonnyr-f5 #193 r3 minor): this same fingerprint is
# _is_release_bot_subject in scripts/lib/is-release-bot-subject.sh, used
# by the commit-lint gate. This `guard` job runs WITHOUT a checkout (it
# reads only the event payload) so it cannot source that file; the two
# grep predicates below are therefore kept BYTE-IDENTICAL to the lib and
# scripts/tests/lint-commit-markers.test.sh (SS-1) asserts they match, so
# they cannot silently diverge.
if grep -qE '^release: v[0-9]+\.[0-9]+\.[0-9]+' <<< "$FIRST" && grep -qE '\[skip ci\]$' <<< "$FIRST"; then
# Our own automated release commit reached the guard anyway (e.g.
# a re-tag or a replay that kept the marker). The release it names
# was already published by the run that created it, so suppressing
# it is expected -- a notice, and the run stays green.
echo "::notice::Loop guard: skipping our own release commit \"$FIRST\" (expected -- it was published by the previous run)."
exit 0
fi
# Any OTHER suppressed commit is unexpected: a hand-written
# [skip ci], a human "release: ..." subject with no marker, or a
# squash-merged PR titled "release: …(#N)". The run publishes
# nothing, so it must NOT report success -- a release that did not
# happen has to be loud, not a silent green (bonnyr-f5 #181 round 3
# and 4). Fail the guard; downstream jobs are gated on should_run and
# stay skipped, so nothing is published either way.
echo "::error::Release suppressed by the loop guard: head commit \"$FIRST\" begins with 'release: ' or carries [skip ci], so nothing was published. To cut a NEW release, push a normal commit whose subject does NOT begin with 'release: ' and carries no skip marker (it will release on merge to main). To re-publish images for an EXISTING tag, dispatch this workflow with publish_only=<tag> — do not manually dispatch a final release on a skip-marked head, GitHub creates no CI run for it and the CI-status check cannot pass."
exit 1
fi
echo "should_run=true" >> "$GITHUB_OUTPUT"
# ── Dry-run: exercise the release-publish TOOLING without publishing ──────────
# bonnyr-f5 #193 r4 B-2 (bonnyr's suggestion): the r3 verify-image-pins step could
# NEVER execute — it ran the script from a sparse .release-tooling checkout that holds
# no compose file, and passed REGISTRY/VERSION as env vars the script ignores — yet it
# sat AFTER the tag/Release/push/signing, so the defect only surfaced post-signature.
# This job rebuilds the EXACT publish-job on-disk layout (full tree at the workspace
# root + the same 4-path sparse .release-tooling) and runs the pin-verify tooling
# against a FAKE probe, so a step that cannot execute is caught HERE — before it is
# ever wired ahead of a signature. release-publish `needs` it, so a broken layout
# blocks the publish instead of failing after it.
dryrun-release-tooling:
name: "Dry-run: release-publish tooling"
needs: guard
if: needs.guard.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout full tree (compose files present at root, as in the tag checkout)
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Materialize the tooling EXACTLY as release-publish does (sparse, no compose)
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
path: .release-tooling
sparse-checkout: |
scripts/registry-tag-probe.sh
scripts/registry-overwrite-guard.sh
scripts/verify-image-pins.sh
docker-bake.hcl
sparse-checkout-cone-mode: false
- name: bash -n the tooling scripts materialized in .release-tooling
run: |
for s in .release-tooling/scripts/*.sh; do bash -n "$s"; done
- name: Prove the POST-PUSH verify step can execute (sparse script + --file + FLAGS, fake probe)
run: |
# No live registry: a fake probe that always "exists" proves the pins RESOLVE
# from the sparse checkout via --file (the r3 bug was rc=1 "no pins"), and that
# REGISTRY/VERSION arrive as FLAGS the script actually reads.
printf '#!/usr/bin/env bash\nexit 0\n' > "$RUNNER_TEMP/fakeprobe"
chmod +x "$RUNNER_TEMP/fakeprobe"
IMAGE_PROBE="$RUNNER_TEMP/fakeprobe" \
bash .release-tooling/scripts/verify-image-pins.sh \
--registry "ghcr.io/${{ github.repository_owner }}" --version 0.0.0-dryrun \
--file dist/docker-compose.yml \
--file dist/docker-compose.local.yml \
--file scripts/ibm_cloud_bnk_forge.sh
- name: Prove the PRE-PUSH consistency gate can execute (committed pins == VERSION)
run: |
# The committed compose pins must equal the repo VERSION (what a real release
# sets $NEW to via sync-version-artifacts.sh --write). Fails loud here if the
# shipped pins have drifted from VERSION — the same gate release-final runs.
bash scripts/verify-image-pins.sh --expect-version "$(cat VERSION)"
# ── Pre-flight: verify CI passed + derive version ────────────────────────────
preflight:
name: "Pre-flight Checks"
needs: guard
if: needs.guard.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read # checkout + read VERSION/tags
actions: read # gh run list --workflow=ci.yml (the CI-status poll)
outputs:
current_version: ${{ steps.version.outputs.current }}
new_version: ${{ steps.version.outputs.new }}
bump_type: ${{ steps.version.outputs.bump_type }}
release_kind: ${{ steps.kind.outputs.kind }}
env:
# Env-indirect the ref name (bonnyr-f5 #181 round 2): a branch name can
# legally carry $(), backticks, ; and | (workflow_dispatch targets any
# branch), so it's read from env in run: blocks, never interpolated —
# same rule this PR applies to release_notes/publish_only.
REF_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history + tags needed for conventional-commit derivation
- name: Determine release kind
id: kind
env:
PUBLISH_ONLY: ${{ inputs.publish_only }}
SIGN_ONLY: ${{ inputs.sign_only }}
run: |
# sign_only is a recovery MODE of publish_only (re-sign already-pushed
# images), not a release path of its own. Refuse it without a target
# tag so it can never be dispatched against a from-scratch build
# (bonnyr-f5 #181 round 5, F2).
if [ "$SIGN_ONLY" = "true" ] && [ -z "$PUBLISH_ONLY" ]; then
echo "::error::sign_only requires publish_only=<tag>: it re-signs the images already published for an EXISTING tag, it does not build a release."
exit 1
fi
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "$PUBLISH_ONLY" ]; then
echo "kind=publish_only" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "kind=manual" >> "$GITHUB_OUTPUT"
elif [ "$REF_NAME" = "main" ]; then
echo "kind=final" >> "$GITHUB_OUTPUT"
else
echo "kind=rc" >> "$GITHUB_OUTPUT"
fi
- name: Restrict manual release to main
if: steps.kind.outputs.kind == 'manual'
env:
DISPATCH_REF: ${{ github.ref }}
run: |
# A manual (non-publish_only) dispatch builds THIS ref's tree, commits
# the version bump to it, tags it, and publishes it as :latest.
# Dispatching from staging or a side branch would ship an unreviewed
# tree as the released :latest, and the recency guard would not catch
# it (a numerically higher version passes: measured ALLOW new=5.0.0
# highest=v4.0.5).
#
# The dispatched ref must BE main itself (refs/heads/main). An earlier
# "ancestor of main" exemption was WRONG: staging sits 0-ahead/1-behind
# main, so `git merge-base --is-ancestor origin/staging origin/main` is
# true, and a manual dispatch on staging slipped through — the exact ref
# this step names as the hazard (release commit+tag+GitHub Release land
# on staging, :latest built from it, main never bumped) (bonnyr-f5 #181
# round 4). Any ancestor of main is by definition already ON main's
# first-parent history if it was merged, so requiring the ref to be main
# loses nothing legitimate. publish_only is exempt (kind != manual): it
# republishes an existing tag by checking that tag out, independent of
# the dispatched ref.
if [ "$DISPATCH_REF" = "refs/heads/main" ]; then
echo "Dispatched from main."
exit 0
fi
echo "::error::A manual final release must be dispatched from main itself (refs/heads/main). '$REF_NAME' (ref '$DISPATCH_REF') is not main — dispatching it would publish an unreviewed tree as :latest. Merge to main and dispatch from there, or use publish_only to republish an existing tag."
exit 1
- name: Check CI status on this branch
if: steps.kind.outputs.kind != 'publish_only'
run: |
BRANCH="$REF_NAME"
SHA="${{ github.sha }}"
echo "Checking CI status for branch '$BRANCH' at commit $SHA"
# Fail FAST on a CI-skip-marked head instead of polling for 2700s.
# After every automated release, main's head is
# "release: vX.Y.Z [skip ci]"; GitHub creates NO CI run for a commit
# carrying a skip marker, so a manual final dispatch on that head would
# poll for a run that will never appear and only surface the problem
# after the full 45-minute timeout. There is no CI to wait for and none
# is coming, so refuse immediately with the real recovery, rather than
# advising a wait (bonnyr-f5 #181 round 4). A genuine change never
# reaches here skip-marked: GitHub drops skip-marked pushes before the
# workflow starts, so this only trips on a manual dispatch of a
# skip-marked head.
HEAD_SUBJECT="$(git log -1 --format=%s HEAD)"
if grep -qiE '\[skip ci\]|\[ci skip\]|\[skip actions\]' <<< "$HEAD_SUBJECT"; then
echo "::error::The head commit \"$HEAD_SUBJECT\" carries a CI-skip marker, so GitHub created no CI run for it and none ever will — waiting would only time out after ${CI_POLL_TIMEOUT_SECONDS}s. This is the state main is left in immediately after an automated release. To cut a NEW release, push a normal (non-skip-marked) commit and let it release on merge to main. To re-publish images for the EXISTING tag, dispatch this workflow with publish_only=<tag>, which skips this CI check."
exit 1
fi
# Match the CI run by the exact commit SHA that triggered this
# release, not by "--limit=1 --branch=X" (which is racy: on main,
# ci.yml and release.yml fire on the same push so --limit=1 can
# return this-same-push's still-running CI run; on staging, a
# branch-name lookup can return a stale run from an unrelated
# earlier push). ci.yml has a push:staging trigger specifically so
# every staging push gets its own CI run carrying that push's SHA.
# Budget: last five green CI runs on this repo took ~18 min
# end-to-end; 2700s (45 min) covers queue delays and future growth.
TIMEOUT_SECONDS="$CI_POLL_TIMEOUT_SECONDS"
POLL_INTERVAL=30
ELAPSED=0
while true; do
# Filter by the commit SHA SERVER-SIDE (--commit), not by fetching the
# newest 20 runs on the branch and grepping (bonnyr-f5 #193 minor): with
# a busy branch, >20 CI runs newer than this SHA pushed the target run off
# the --limit=20 page, so the poll never saw it and the release timed out
# claiming no run existed. --commit returns only this SHA's runs, so the
# page holds every attempt for it; the jq keeps the latest attempt.
RUN_JSON=$(gh run list \
--workflow=ci.yml \
--branch="$BRANCH" \
--commit="$SHA" \
--limit=20 \
--json headSha,status,conclusion,databaseId \
--jq "[.[] | select(.headSha == \"${SHA}\")] | sort_by(.databaseId) | last" 2>/dev/null || echo "")
if [ -z "$RUN_JSON" ] || [ "$RUN_JSON" = "null" ]; then
echo "[${ELAPSED}s] No CI run found yet for commit $SHA on branch '$BRANCH'"
else
RUN_STATUS=$(echo "$RUN_JSON" | jq -r '.status')
RUN_CONCLUSION=$(echo "$RUN_JSON" | jq -r '.conclusion')
echo "[${ELAPSED}s] CI run status=$RUN_STATUS conclusion=$RUN_CONCLUSION"
if [ "$RUN_STATUS" = "completed" ]; then
if [ "$RUN_CONCLUSION" = "success" ]; then
echo "CI has passed for commit $SHA on branch '$BRANCH'"
exit 0
fi
if [ "$RUN_CONCLUSION" = "cancelled" ]; then
# A cancelled CI run is not a success for this SHA, so fail
# fast rather than reporting a generic non-success error.
# NOTE (premise updated for #182): ci.yml does NOT cancel
# in-progress runs on main/staging — cancel-in-progress is
# false for exactly these release branches (ci.yml:48), each
# push gets its own concurrency group. So a cancellation here
# is no longer necessarily "a newer push superseded it"; it may
# have been cancelled by other means (e.g. a manual cancel).
# Either way the run is stale — do not release on it.
echo "::error::CI run for $SHA was cancelled — this release attempt is stale (a newer push, if any, will release instead)."
exit 1
fi
echo "::error::CI run for commit $SHA on branch '$BRANCH' completed with conclusion '$RUN_CONCLUSION'."
exit 1
fi
fi
if [ "$ELAPSED" -ge "$TIMEOUT_SECONDS" ]; then
echo "::error::Timed out after ${TIMEOUT_SECONDS}s waiting for a completed CI run matching commit $SHA on branch '$BRANCH'."
echo "Re-run this workflow once the CI run for this commit finishes: https://github.com/${{ github.repository }}/actions/workflows/ci.yml"
exit 1
fi
sleep "$POLL_INTERVAL"
ELAPSED=$((ELAPSED + POLL_INTERVAL))
done
env:
GH_TOKEN: ${{ github.token }}
CI_POLL_TIMEOUT_SECONDS: 2700
- name: Derive version from conventional commits
id: version
env:
PUBLISH_ONLY: ${{ inputs.publish_only }}
run: |
chmod +x scripts/compute_version_bump.sh
RELEASE_KIND="${{ steps.kind.outputs.kind }}"
CURRENT=$(cat VERSION)
# Validate before it reaches $GITHUB_OUTPUT: a newline in VERSION would
# inject a second output key, and current_version is interpolated into
# several later run: blocks (bonnyr-f5 #181 round 2).
if [[ ! "$CURRENT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::VERSION file contents '$CURRENT' are not a valid MAJOR.MINOR.PATCH version."
exit 1
fi
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
if [ "$RELEASE_KIND" = "publish_only" ]; then
# Recovery path: no derivation, no bump. Republish an existing tag.
# publish_only is free-text, so read it from env (never inline it into
# the script) and validate its shape before use (#181 review).
TAG="$PUBLISH_ONLY"
if [[ ! "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::publish_only='$TAG' is not a final release tag (vMAJOR.MINOR.PATCH). Republish repoints :latest across all images and must not point it at an rc/pre-release or an arbitrary string."
exit 1
fi
NEW="${TAG#v}"
BUMP="republish"
elif [ "$RELEASE_KIND" = "manual" ]; then
# Manual override: use the dropdown input directly
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "${{ inputs.version_bump }}" in
major) NEW="$((MAJOR + 1)).0.0" ;;
minor) NEW="${MAJOR}.$((MINOR + 1)).0" ;;
patch) NEW="${MAJOR}.${MINOR}.$((PATCH + 1))" ;;
esac
BUMP="${{ inputs.version_bump }}"
else
# Automated: derive from conventional commits.
# Capture output before eval — `eval $(cmd)` on its own returns
# eval's own exit status (almost always 0), swallowing a nonzero
# exit from compute_version_bump.sh (e.g. its fail-safe guard).
BUMP_OUTPUT=$(bash scripts/compute_version_bump.sh)
eval "$BUMP_OUTPUT"
NEW="$TARGET_VERSION"
BUMP="$BUMP_TYPE"
fi
# :latest recency guard — covers the paths that both MINT a new tag and
# repoint :latest to it: final and manual. A version below the highest
# final tag would drag :latest backward (bonnyr-f5 #181 round 2 —
# release-manual from a maintenance branch could tag+publish a version
# below the highest final tag). rc tags are pre-releases and never touch
# :latest, so they're exempt.
#
# publish_only is NOT hard-failed here: a republish re-emits the
# IMMUTABLE :VERSION tags of an ALREADY-released version whose original
# publish half-completed, and it owes those tags to consumers regardless
# of what has been released since. Failing it on recency stranded it
# forever — once any newer tag existed, the half-published version's
# images could never be produced by ANY path (bonnyr-f5 #181 round 4).
# A republish must still never move :latest backward, but that is a
# decision about the FLOATING tag only, and it is made authoritatively
# inside the publish job's critical section (see "Re-check recency"),
# not here. :latest is set by whatever release-publish last ran, not by
# this ref's VERSION file, so that check compares against the highest
# FINAL tag at push time.
if [ "$RELEASE_KIND" = "final" ] || [ "$RELEASE_KIND" = "manual" ]; then
HIGHEST_TAG="$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)"
HIGHEST="$(printf '%s\n%s\n' "${HIGHEST_TAG#v}" "$NEW" | sort -V | tail -1)"
if [ -n "$HIGHEST_TAG" ] && [ "$NEW" != "$HIGHEST" ]; then
echo "::error::Release v$NEW is older than the highest released tag $HIGHEST_TAG; publishing would move :latest backward."
exit 1
fi
fi
echo "new=$NEW" >> "$GITHUB_OUTPUT"
echo "bump_type=$BUMP" >> "$GITHUB_OUTPUT"
echo "Version: $CURRENT -> $NEW (bump: $BUMP)"
- name: Check republish tag exists
if: steps.kind.outputs.kind == 'publish_only'
run: |
TAG="v${{ steps.version.outputs.new }}"
if ! git tag -l "$TAG" | grep -q "^${TAG}$"; then
echo "::error::publish_only requested tag $TAG, which does not exist. Republish only targets an already-created tag."
exit 1
fi
echo "Republishing images for existing tag $TAG"
- name: Check final tag doesn't already exist
if: steps.kind.outputs.kind != 'rc' && steps.kind.outputs.kind != 'publish_only'
run: |
TAG="v${{ steps.version.outputs.new }}"
if git tag -l "$TAG" | grep -q "^${TAG}$"; then
echo "::error::Tag $TAG already exists"
exit 1
fi
echo "Tag $TAG is available"
# ── Optional: Run E2E Tests (manual path only) ───────────────────────────────
e2e-gate:
name: "E2E Gate"
needs: preflight
if: needs.preflight.outputs.release_kind == 'manual' && inputs.run_e2e == true
uses: ./.github/workflows/e2e-tests.yml
with:
environment: local
# ── RC Release (staging push) ────────────────────────────────────────────────
release-rc:
name: "Pre-release RC v${{ needs.preflight.outputs.new_version }}"
needs: preflight
if: needs.preflight.outputs.release_kind == 'rc'
runs-on: ubuntu-latest
permissions:
contents: write
env:
REF_NAME: ${{ github.ref_name }} # env-indirected — see preflight
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Compute RC number
id: rc
run: |
TARGET="${{ needs.preflight.outputs.new_version }}"
# Highest existing rc number for this target + 1. Max-based, not
# count-based (#177 review): counting breaks if any rc tag is ever
# deleted -- the count drops and the next push recomputes an existing
# tag, which then fails to create.
# NB: this step must NOT `set -o pipefail`. `grep -E` returns 1 when a
# version has no rc tags yet; without pipefail the substitution takes
# tail's status and ${RC_MAX:-0} yields the first rc as 1. Adding
# pipefail here would fail rc.1 of every new version.
# Escape TARGET's dots so the sed anchor matches them literally, not
# as "any char" (bonnyr-f5 #181 round 2). The grep -l glob already
# pre-filters to real tags, but a literal-dot pattern is correct.
TARGET_RE="${TARGET//./\\.}"
RC_MAX=$(git tag -l "v${TARGET}-rc.*" \
| sed -E "s|^v${TARGET_RE}-rc\.([0-9]+)$|\1|" \
| grep -E '^[0-9]+$' | sort -n | tail -1)
RC_NUM=$(( ${RC_MAX:-0} + 1 ))
echo "rc_num=${RC_NUM}" >> "$GITHUB_OUTPUT"
echo "rc_tag=v${TARGET}-rc.${RC_NUM}" >> "$GITHUB_OUTPUT"
echo "RC tag will be: v${TARGET}-rc.${RC_NUM}"
# bonnyr-f5 #193 r4 M-5 / INV-31: create the tag LOCALLY here but do NOT push it
# yet. The RC notes below run extract-breaking-changes.sh, which is fail-closed
# (exit 1 on a bad range). Generating notes AFTER the tag push previously left an
# RC tag on the remote with no pre-release when notes failed — the same
# irreversible-push-before-fail-closed-step class fixed in release-final. The push
# now happens AFTER notes succeed (see "Push RC tag").
- name: Create annotated RC tag (local)
run: |
RC_TAG="${{ steps.rc.outputs.rc_tag }}"
TARGET="${{ needs.preflight.outputs.new_version }}"
BUMP="${{ needs.preflight.outputs.bump_type }}"
git tag -a "$RC_TAG" \
-m "Pre-release ${RC_TAG}
Target: v${TARGET} (${BUMP} bump)
Branch: ${REF_NAME}
Commit: ${{ github.sha }}"
- name: Generate RC release notes
id: notes
run: |
TARGET="${{ needs.preflight.outputs.new_version }}"
BUMP="${{ needs.preflight.outputs.bump_type }}"
RC_TAG="${{ steps.rc.outputs.rc_tag }}"
# Find the last final tag for the commit range, ancestry-filtered to HEAD so
# a higher tag cut on another branch cannot skew LAST_FINAL..HEAD (#193 r4).
LAST_FINAL=$(git tag -l 'v*' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| while IFS= read -r t; do git merge-base --is-ancestor "$t" HEAD 2>/dev/null && echo "$t"; done \
| sort -V | tail -1)
NOTES="## Pre-release ${RC_TAG}
**Target release:** v${TARGET} (${BUMP} bump)
**Branch:** ${REF_NAME}
**Commit:** ${{ github.sha }}
### Commits since ${LAST_FINAL:-initial}
"
# Cap the commit list, but say so when it truncates -- a silent `head`
# dropped 17 of 67 commits from published notes with no indication
# (bonnyr-f5 #179 r3). CAP is generous enough that normal ranges are
# complete; a larger range appends an explicit "and N more" line.
CAP=300
if [ -n "$LAST_FINAL" ]; then
FULL_LOG=$(git log "${LAST_FINAL}..HEAD" --pretty=format:"- %s")
BREAKING=$(bash scripts/extract-breaking-changes.sh "$LAST_FINAL" HEAD)
else
FULL_LOG=$(git log --pretty=format:"- %s")
BREAKING=""
fi
COMMIT_LOG=$(printf '%s\n' "$FULL_LOG" | head -"$CAP")
TOTAL=$(printf '%s\n' "$FULL_LOG" | grep -c '^-' || true)
if [ "$TOTAL" -gt "$CAP" ]; then
COMMIT_LOG=$(printf '%s\n- … and %d more commit(s) — see the full compare view' "$COMMIT_LOG" "$((TOTAL - CAP))")
fi
if [ -n "$BREAKING" ]; then
printf '%s\n\n%s\n\n%s' "$NOTES" "$BREAKING" "$COMMIT_LOG" > /tmp/rc_notes.md
else
printf '%s\n\n%s' "$NOTES" "$COMMIT_LOG" > /tmp/rc_notes.md
fi
echo "notes_file=/tmp/rc_notes.md" >> "$GITHUB_OUTPUT"
# bonnyr-f5 #193 r4 M-5 / INV-31: the fail-closed notes step above has passed, so
# the push is now safe — nothing irreversible happened before it.
- name: Push RC tag
run: git push origin "${{ steps.rc.outputs.rc_tag }}"
- name: Create GitHub pre-release
run: |
gh release create "${{ steps.rc.outputs.rc_tag }}" \
--title "${{ steps.rc.outputs.rc_tag }}" \
--notes-file "${{ steps.notes.outputs.notes_file }}" \
--prerelease \
--target "${REF_NAME}"
env:
GH_TOKEN: ${{ github.token }}
- name: RC release summary
run: |
echo "## Pre-release ${{ steps.rc.outputs.rc_tag }}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Item | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "|------|-------|" >> "$GITHUB_STEP_SUMMARY"
echo "| RC Tag | ${{ steps.rc.outputs.rc_tag }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Target Version | v${{ needs.preflight.outputs.new_version }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Bump Type | ${{ needs.preflight.outputs.bump_type }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Branch | ${REF_NAME} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Commit | ${{ github.sha }} |" >> "$GITHUB_STEP_SUMMARY"
# ── Final Release (main push) ─────────────────────────────────────────────────
release-final:
name: "Final Release v${{ needs.preflight.outputs.new_version }}"
needs: preflight
if: needs.preflight.outputs.release_kind == 'final'
runs-on: ubuntu-latest
permissions:
contents: write
packages: read # bonnyr-f5 #193 M4: the pre-push overwrite-guard reads ghcr manifests
env:
REF_NAME: ${{ github.ref_name }} # env-indirected — see preflight
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump VERSION file
run: |
NEW="${{ needs.preflight.outputs.new_version }}"
echo "$NEW" > VERSION
# Update dist/VERSION if it is tracked
if git ls-files --error-unmatch dist/VERSION 2>/dev/null; then
echo "$NEW" > dist/VERSION
fi
# Keep the Helm chart tag/appVersion and frontend package.json in
# lockstep so the chart never pins an image tag the release doesn't
# publish (#177 Blocker 2).
bash scripts/sync-version-artifacts.sh --write "$NEW"
- name: Update CHANGELOG.md
run: |
NEW="${{ needs.preflight.outputs.new_version }}"
DATE=$(date +%Y-%m-%d)
BUMP="${{ needs.preflight.outputs.bump_type }}"
# Find the last final tag for the commit range. Ancestry-filter to HEAD
# (bonnyr-f5 #193 r4 minor): a numerically-higher tag cut on ANOTHER branch
# is not on this history, so `git tag | sort -V | tail -1` could pick it and
# yield a nonsensical LAST_FINAL..HEAD range. Only tags reachable from HEAD
# (merged into this release ref) are candidates; then take the highest.
LAST_FINAL=$(git tag -l 'v*' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| while IFS= read -r t; do git merge-base --is-ancestor "$t" HEAD 2>/dev/null && echo "$t"; done \
| sort -V | tail -1)
# Cap the commit list but say so on truncation -- a silent `head -50`
# dropped 17 of 67 commits from published notes (bonnyr-f5 #179 r3).
# The `|| true` here guards the FILTER only (an all-"release:" range
# leaves grep -v with no output, rc 1 under pipefail). extract-breaking-
# changes.sh is itself fail-closed now — #179's rewrite is in-tree and
# `exit 1`s on a bad range with no `|| true` (bonnyr-f5 #193 minor: the
# old comment here claiming this PR does not touch that script and that
# it still ends its range query with `|| true` at line 33 was stale).
CAP=300
if [ -n "$LAST_FINAL" ]; then
FULL_LOG=$(git log "${LAST_FINAL}..HEAD" --pretty=format:"- %s" | { grep -v "^- release: " || true; })
BREAKING=$(bash scripts/extract-breaking-changes.sh "$LAST_FINAL" HEAD)
else
FULL_LOG=$(git log --pretty=format:"- %s" | { grep -v "^- release: " || true; })
BREAKING=""
fi
COMMITS=$(printf '%s\n' "$FULL_LOG" | head -"$CAP")
TOTAL=$(printf '%s\n' "$FULL_LOG" | grep -c '^-' || true)
if [ "$TOTAL" -gt "$CAP" ]; then
COMMITS=$(printf '%s\n- … and %d more commit(s) — see the full compare view' "$COMMITS" "$((TOTAL - CAP))")
fi
# Build the entry in a temp file rather than interpolating COMMITS
# (multi-line, and any commit subject containing |, &, \, or
# newlines) into a sed s-command — that breaks with "unterminated
# `s' command". Insert via awk instead: it reads the entry from a
# file, so no commit content ever passes through a shell/sed
# expression.
ENTRY_FILE=$(mktemp)
{
echo "## v${NEW} (${DATE}) — ${BUMP} bump"
echo ""
if [ -n "$BREAKING" ]; then
echo "$BREAKING"
echo ""
fi
echo "$COMMITS"
} > "$ENTRY_FILE"
# Insert after the FIRST "---" separator only.
awk -v entry="$ENTRY_FILE" '
!done && /^---$/ {
print
print ""
while ((getline line < entry) > 0) print line
done = 1
next
}
{ print }
' CHANGELOG.md > CHANGELOG.md.new
# Fail CLOSED if the insertion was a no-op: the awk anchors on the first
# `^---$`, and if that separator is ever absent every line passes through
# unchanged with rc 0 — the entry is silently dropped and the release
# ships with no CHANGELOG record (bonnyr-f5 #193 minor). Assert the output
# actually grew before replacing the file.
if cmp -s CHANGELOG.md CHANGELOG.md.new; then
echo "::error::CHANGELOG.md insertion was a no-op (no '---' anchor found?) — refusing to commit a release with no changelog entry."
rm -f CHANGELOG.md.new "$ENTRY_FILE"
exit 1
fi
mv CHANGELOG.md.new CHANGELOG.md
rm -f "$ENTRY_FILE"
- name: Commit and tag
run: |
NEW="${{ needs.preflight.outputs.new_version }}"
BUMP="${{ needs.preflight.outputs.bump_type }}"
# Stage VERSION, dist/VERSION (if tracked), CHANGELOG, and the
# version-bearing artifacts synced above (#177 Blocker 2).
git add VERSION CHANGELOG.md
# Stage EXACTLY the artifacts sync-version-artifacts.sh owns, from its
# own --list, so a newly-synced file can never be left unstaged and die
# with the runner (bonnyr-f5 #180 r3, BLOCKER 1: --write rewrote five
# files, the hard-coded `git add` staged three).
# LEAD (bonnyr-f5 #193 r4): derive the anti-vacuity floor from the artifact
# list ITSELF, not a stale literal. --list yields 8 paths today (the dist/+IBM
# pins added to close B-1); the old `-lt 5` left three of them free to vanish
# and still pass. EXPECTED tracks the true set and every listed path must stage
# (staged == EXPECTED), so a dropped path is caught; an empty/near-empty --list
# (script broke/truncated) trips EXPECTED<1 here AND the script's own
# `--check total < 8` vacuity floor. The old comment's "mirrors --check
# total < 5" was doubly stale — that guard is now < 8 and counts matched LINES
# (21), not paths. The per-file "not fully staged" check below still verifies
# each staged path individually.
EXPECTED=$(bash scripts/sync-version-artifacts.sh --list | grep -c . || true)
staged=0
while IFS= read -r f; do git add "$f"; staged=$((staged + 1)); done < <(bash scripts/sync-version-artifacts.sh --list)
if [ "$EXPECTED" -lt 1 ] || [ "$staged" -ne "$EXPECTED" ]; then
echo "::error::sync-version-artifacts.sh --list: staged $staged of $EXPECTED path(s) — refusing to commit an unsynced release"; exit 1
fi
# Verify the INDEX, not the files: --write's post-write check re-reads
# the files (correct on disk even when unstaged), so assert each synced
# artifact has no unstaged residue — i.e. the sync is actually in the
# commit we are about to make.
while IFS= read -r f; do
git diff --quiet -- "$f" || { echo "::error::$f was synced but is not fully staged"; exit 1; }
done < <(bash scripts/sync-version-artifacts.sh --list)
# Stage dist/VERSION if it is tracked. `git add` of a tracked path can
# only fail for a real reason (permission, corrupt index), so do NOT
# swallow it with `|| true` — that would silently drop the dist bump from
# the release commit (bonnyr-f5 #193 minor). The ls-files guard already
# makes this a no-op when dist/VERSION is untracked.
if git ls-files --error-unmatch dist/VERSION >/dev/null 2>&1; then
git add dist/VERSION
fi
git commit -m "release: v${NEW} [skip ci]
Automated release commit.
Bump: ${BUMP}
Previous: v${{ needs.preflight.outputs.current_version }}
CI: passed"
git tag -a "v${NEW}" \
-m "Release v${NEW} (${BUMP} bump)"
# bonnyr-f5 #193 M4 / INV-31: generate the release notes BEFORE the
# irreversible push. extract-breaking-changes.sh is fail-closed (exit 1 on a
# bad range, no `|| true`), so a failure here previously left main bumped and
# the tag pushed with no Release. Generating notes ahead of the push keeps
# the fail-closed step in front of anything irreversible; the output is
# consumed by "Create GitHub Release" after the push.
- name: Generate final release notes
id: notes
run: |
NEW="${{ needs.preflight.outputs.new_version }}"
BUMP="${{ needs.preflight.outputs.bump_type }}"
# The local tag v$NEW was just created by "Commit and tag", so exclude it
# explicitly to find the PREVIOUS final tag. The old `tail -2 | head -1`
# returned the just-created tag on a first-ever release (only one tag
# exists), giving an empty v$NEW..HEAD range and empty notes (bonnyr-f5
# #193 minor). grep -vx is robust whether or not the new tag is present.
# Exclude the just-created v$NEW tag AND ancestry-filter to HEAD so a
# higher tag on another branch cannot become LAST_FINAL (bonnyr-f5 #193 r4).
LAST_FINAL=$(git tag -l 'v*' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| grep -vx "v${NEW}" \
| while IFS= read -r t; do git merge-base --is-ancestor "$t" HEAD 2>/dev/null && echo "$t"; done \
| sort -V | tail -1)
# Cap the commit list but say so on truncation -- a silent `head -50`
# dropped 17 of 67 commits from published notes (bonnyr-f5 #179 r3). The
# `|| true` below guards the FILTER only (an all-"release:" range leaves
# grep -v with no output, rc 1 under pipefail); extract-breaking-changes.sh
# is itself fail-closed on a bad range (it now `exit 1`s, no `|| true`),
# and this step runs BEFORE the push (INV-31), so a bad range fails the
# release before anything irreversible.
CAP=300
if [ -n "$LAST_FINAL" ]; then
FULL_LOG=$(git log "${LAST_FINAL}..HEAD" --pretty=format:"- %s" | { grep -v "^- release: " || true; })
BREAKING=$(bash scripts/extract-breaking-changes.sh "$LAST_FINAL" HEAD)
else
FULL_LOG=$(git log --pretty=format:"- %s" | { grep -v "^- release: " || true; })
BREAKING=""
fi
COMMITS=$(printf '%s\n' "$FULL_LOG" | head -"$CAP")
TOTAL=$(printf '%s\n' "$FULL_LOG" | grep -c '^-' || true)
if [ "$TOTAL" -gt "$CAP" ]; then
COMMITS=$(printf '%s\n- … and %d more commit(s) — see the full compare view' "$COMMITS" "$((TOTAL - CAP))")
fi
{
echo "## v${NEW} — ${BUMP} bump"
echo ""
if [ -n "$BREAKING" ]; then
echo "$BREAKING"
echo ""
fi
echo "$COMMITS"
} > /tmp/release_notes.md
echo "notes_file=/tmp/release_notes.md" >> "$GITHUB_OUTPUT"
# bonnyr-f5 #193 M4 / INV-31: refuse a republish of an already-published
# immutable :VERSION tag BEFORE the push, not only inside release-publish
# (which runs after these pushes). Nothing irreversible happens before this
# fail-closed check. release-publish keeps its own authoritative in-critical-
# section re-check for the concurrency TOCTOU.
- name: Refuse to overwrite an already-published tag (pre-push)
env:
FORCE: ${{ inputs.force }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
VERSION: ${{ needs.preflight.outputs.new_version }}
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: bash scripts/registry-overwrite-guard.sh
# bonnyr-f5 #193 r4 B-2 (PRIMARY pin gate): assert BEFORE the push that every
# shipped first-party compose pin already equals v$NEW. sync-version-artifacts.sh
# --write ran above, so the committed pins should be $NEW; if any is stale/forward-
# dated (the B-1 class dist/ pinned 4.0.0 nobody published), fail CLOSED here —
# before the tag/GitHub Release/image push/signing, while it is still recoverable.
# A post-push probe cannot retract those (INV-31). Run from the workspace root
# (full tag checkout — the compose files are present), NOT from the sparse
# .release-tooling. NO --version: the check must read the COMMITTED default.
- name: Verify shipped compose pins equal the release version (pre-push)
run: bash scripts/verify-image-pins.sh --expect-version "${{ needs.preflight.outputs.new_version }}"
- name: Push commit and tag
run: |
git push origin "${REF_NAME}"
git push origin "v${{ needs.preflight.outputs.new_version }}"
- name: Create GitHub Release
run: |
gh release create "v${{ needs.preflight.outputs.new_version }}" \
--title "v${{ needs.preflight.outputs.new_version }}" \
--notes-file "${{ steps.notes.outputs.notes_file }}" \
--target "${REF_NAME}"
env:
GH_TOKEN: ${{ github.token }}
- name: Final release summary
run: |
echo "## Release v${{ needs.preflight.outputs.new_version }}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Item | Value |" >> "$GITHUB_STEP_SUMMARY"
echo "|------|-------|" >> "$GITHUB_STEP_SUMMARY"
echo "| Version | ${{ needs.preflight.outputs.current_version }} -> v${{ needs.preflight.outputs.new_version }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Bump | ${{ needs.preflight.outputs.bump_type }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Branch | ${REF_NAME} |" >> "$GITHUB_STEP_SUMMARY"
echo "| Commit | ${{ github.sha }} |" >> "$GITHUB_STEP_SUMMARY"
# ── Manual Release (workflow_dispatch) ───────────────────────────────────────
release-manual:
name: "Manual Release v${{ needs.preflight.outputs.new_version }}"
needs:
- preflight
- e2e-gate
if: |
always() &&
needs.preflight.outputs.release_kind == 'manual' &&
needs.preflight.result == 'success' &&
(needs.e2e-gate.result == 'success' || needs.e2e-gate.result == 'skipped')
runs-on: ubuntu-latest
permissions:
contents: write
packages: read # bonnyr-f5 #193 M4: the pre-push overwrite-guard reads ghcr manifests
env:
# bonnyr-f5 #181: release_notes is free-text; read it from env so a value
# with " or $() can't break out of a run: script (same rule as publish_only).
RELEASE_NOTES: ${{ inputs.release_notes }}
REF_NAME: ${{ github.ref_name }} # env-indirected — see preflight
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Lint the release notes before they become a commit
env:
# Untrusted free text -> env, NEVER interpolated into the shell (same rule
# as RELEASE_NOTES itself). Empty when no notes were given -> a no-op.
LINT_MESSAGE: ${{ inputs.release_notes }}
LINT_MESSAGE_LABEL: "release_notes input"
run: |
# bonnyr-f5 #193 M1: inputs.release_notes is interpolated into the release
# COMMIT body and the TAG message below, but was linted NOWHERE. Lint it
# HERE, before it is minted, through the SAME commit-lint script CI/pre-push
# use: a CI-control marker (which would suppress the workflow run) or a
# BREAKING CHANGE marker the version detectors would MISS (a mis-anchored
# note that ships the release silently as a patch) is caught while it can
# still be fixed — not after it is an unamendable commit on main. RANGE is
# an empty range so ONLY the LINT_MESSAGE text is checked (no commits).
RANGE="HEAD..HEAD" bash scripts/lint-commit-markers.sh
- name: Bump version
run: |
echo "${{ needs.preflight.outputs.new_version }}" > VERSION
if git ls-files --error-unmatch dist/VERSION 2>/dev/null; then
echo "${{ needs.preflight.outputs.new_version }}" > dist/VERSION
fi
bash scripts/sync-version-artifacts.sh --write "${{ needs.preflight.outputs.new_version }}"
- name: Update changelog
run: |
NEW_VERSION="${{ needs.preflight.outputs.new_version }}"
DATE=$(date +%Y-%m-%d)
NOTES="${RELEASE_NOTES}"
# See the "Update CHANGELOG.md" step in release-final for why this
# goes through a temp file + awk instead of an inline sed s-command
# (release_notes can contain multi-line text or |, &, \).
ENTRY_FILE=$(mktemp)
{
echo "## v${NEW_VERSION} (${DATE})"
echo ""
echo "$NOTES"
} > "$ENTRY_FILE"
awk -v entry="$ENTRY_FILE" '
!done && /^---$/ {
print
print ""
while ((getline line < entry) > 0) print line
done = 1
next
}
{ print }
' CHANGELOG.md > CHANGELOG.md.new
# Fail CLOSED if the awk insertion was a no-op (missing `^---$` anchor),
# so a release never ships with a silently-dropped changelog entry
# (bonnyr-f5 #193 minor).
if cmp -s CHANGELOG.md CHANGELOG.md.new; then
echo "::error::CHANGELOG.md insertion was a no-op (no '---' anchor found?) — refusing to commit a release with no changelog entry."
rm -f CHANGELOG.md.new "$ENTRY_FILE"