Repository navigation
572 lines (560 loc) · 26.1 KB
/
Copy pathrelease.yml
File metadata and controls
572 lines (560 loc) · 26.1 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
---
# yamllint disable rule:line-length rule:truthy
name: release
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: semantic-release-main
cancel-in-progress: false
jobs:
activation:
runs-on: ubuntu-latest
permissions: {}
outputs:
enabled: ${{ steps.gate.outputs.enabled }}
steps:
- name: Enforce the reviewed release switch
id: gate
env:
RELEASE_ENABLED: ${{ vars.SEMANTIC_RELEASE_ENABLED }}
run: |
if [ "$RELEASE_ENABLED" != "true" ]; then
echo "Semantic release is disarmed. See README activation prerequisites."
echo "enabled=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "enabled=true" >> "$GITHUB_OUTPUT"
materialize:
needs: activation
if: needs.activation.outputs.enabled == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
previous_version: ${{ steps.intent.outputs.previous_version }}
released: ${{ steps.intent.outputs.released }}
release_sha: ${{ steps.identity.outputs.release_sha }}
source_artifact_name: ${{ steps.identity.outputs.source_artifact_name }}
tag: ${{ steps.identity.outputs.tag }}
version: ${{ steps.identity.outputs.version }}
steps:
- name: Check out the triggering main revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Install the locked toolchain (mise.toml)
uses: jdx/mise-action@82a612c5ab8bcda7cc5db6b7e81a8e7584c3dc6e # v5.2.3
with:
# Pinned so every run, release jobs included, installs the same mise;
# the action still verifies it against mise's signed checksums.
version: "2026.10.18"
- name: Attach the exact trigger to local main
env:
EXPECTED_SHA: ${{ github.sha }}
run: mise run release-attach-trigger
- name: Install the frozen release toolchain
run: uv sync --frozen
- name: Validate the tagged baseline and strict release intent
id: intent
run: |
baseline="$(uv run python scripts/release_contract.py validate-baseline --repository .)"
baseline_tag="$(python -c 'import json,sys; print(json.load(sys.stdin)["tag"])' <<< "$baseline")"
uv run python scripts/release_contract.py validate-history \
--repository . --baseline-tag "$baseline_tag"
previous_version="$(uv run semantic-release version --print-last-released)"
version="$(uv run semantic-release version --print)"
{
echo "previous_version=$previous_version"
if [ -z "$version" ] || [ "$version" = "$previous_version" ]; then
echo "No patch, minor, or breaking release intent." >&2
echo "released=false"
else
tag="v$version"
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "Refusing existing release tag $tag" >&2
exit 1
fi
echo "released=true"
echo "version=$version"
fi
} >> "$GITHUB_OUTPUT"
- name: Materialize the release commit and tag locally
if: steps.intent.outputs.released == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
uv run semantic-release --strict version --no-push --no-vcs-release
- name: Bind the final local release identity
if: steps.intent.outputs.released == 'true'
id: identity
env:
EXPECTED_PARENT: ${{ github.sha }}
EXPECTED_VERSION: ${{ steps.intent.outputs.version }}
run: |
release_sha="$(git rev-parse HEAD)"
tag="v$EXPECTED_VERSION"
test "$(git rev-parse HEAD^)" = "$EXPECTED_PARENT"
test "$(git rev-list -n 1 "$tag")" = "$release_sha"
test -z "$(git status --porcelain --untracked-files=no)"
unexpected="$(git diff --name-only "$EXPECTED_PARENT" "$release_sha" | grep -Ev '^(CHANGELOG\.md|pyproject\.toml|uv\.lock)$' || true)"
test -z "$unexpected"
{
echo "release_sha=$release_sha"
echo "tag=$tag"
echo "version=$EXPECTED_VERSION"
echo "source_artifact_name=release-source-$EXPECTED_VERSION-$release_sha"
} >> "$GITHUB_OUTPUT"
- name: Materialize the immutable release source bundle before tests
if: steps.intent.outputs.released == 'true'
env:
RELEASE_SHA: ${{ steps.identity.outputs.release_sha }}
TAG: ${{ steps.identity.outputs.tag }}
run: |
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
git branch release-candidate "$RELEASE_SHA"
git bundle create release-source.bundle \
refs/heads/release-candidate "refs/tags/$TAG"
git branch --delete --force release-candidate
sha256sum release-source.bundle > release-source.sha256
- name: Upload the immutable release source
if: steps.intent.outputs.released == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.identity.outputs.source_artifact_name }}
path: |
release-source.bundle
release-source.sha256
if-no-files-found: error
compression-level: 0
retention-days: 90
immutable-release-control:
needs: materialize
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
environment: source-promotion
permissions:
contents: read
outputs:
enabled: ${{ steps.verify.outputs.enabled }}
steps:
- name: Fail closed unless immutable releases are enabled
id: verify
env:
GH_TOKEN: ${{ secrets.SOURCE_PROMOTION_TOKEN }}
run: |
: "${GH_TOKEN:?SOURCE_PROMOTION_TOKEN must be configured in source-promotion}"
enabled="$(gh api "repos/$GITHUB_REPOSITORY/immutable-releases" --jq '.enabled')"
test "$enabled" = "true"
echo "enabled=true" >> "$GITHUB_OUTPUT"
unit-public-tests:
needs: materialize
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out a fresh trigger workspace
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Install the locked toolchain (mise.toml)
uses: jdx/mise-action@82a612c5ab8bcda7cc5db6b7e81a8e7584c3dc6e # v5.2.3
with:
# Pinned so every run, release jobs included, installs the same mise;
# the action still verifies it against mise's signed checksums.
version: "2026.10.18"
- name: Download the immutable release source
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.materialize.outputs.source_artifact_name }}
- name: Restore and verify the exact release source
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
sha256sum --check release-source.sha256
git bundle verify release-source.bundle
git fetch release-source.bundle \
refs/heads/release-candidate:refs/heads/release-candidate \
"refs/tags/$TAG:refs/tags/$TAG"
git checkout --detach "$RELEASE_SHA"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
- name: Test the exact SHA with unit and public contracts
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
mise run test
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
hermes-contract:
needs: materialize
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out a fresh isolated trigger workspace
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Install the locked toolchain (mise.toml)
uses: jdx/mise-action@82a612c5ab8bcda7cc5db6b7e81a8e7584c3dc6e # v5.2.3
with:
# Pinned so every run, release jobs included, installs the same mise;
# the action still verifies it against mise's signed checksums.
version: "2026.10.18"
- name: Download the immutable release source
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.materialize.outputs.source_artifact_name }}
- name: Restore and verify the exact release source
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
sha256sum --check release-source.sha256
git bundle verify release-source.bundle
git fetch release-source.bundle \
refs/heads/release-candidate:refs/heads/release-candidate \
"refs/tags/$TAG:refs/tags/$TAG"
git checkout --detach "$RELEASE_SHA"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
# Gate the release on the revision this kit claims to support, not on
# whatever upstream happens to be today. A release promises conformance
# at the deployed pin; upstream drift is the scheduled hermes-drift
# lane's job, and gating here on a moving target means an upstream break
# we have deliberately scoped out blocks every release. That is not
# hypothetical: #99220 landed 2026-09-08 and silently blocked this lane
# until the next release run two weeks later.
- name: Prove the exact SHA against the deployed Hermes pin
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
mise run test-contract-pinned
# Record the revision actually exercised, from the checkout the
# pinned lane created -- not the constant, so the evidence reflects
# what ran. Cross-check it against the constant so a renamed
# directory or a drifted checkout fails here instead of shipping
# evidence naming a revision the suite never saw.
git -C .hermes-agent-pinned rev-parse HEAD > hermes-source-sha.txt
expected="$(uv run python -c 'from hermes_plugin_kit.testing import DEPLOYED_HERMES_REVISION as r; print(r)')"
test "$(cat hermes-source-sha.txt)" = "$expected"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
- name: Upload isolated Hermes evidence only
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: hermes-evidence-${{ needs.materialize.outputs.release_sha }}
path: hermes-source-sha.txt
if-no-files-found: error
retention-days: 90
build:
needs: [materialize, unit-public-tests, hermes-contract]
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
environment: private-artifacts
permissions:
contents: read
outputs:
bundle_reference: ${{ steps.stage.outputs.bundle_reference }}
release_sha: ${{ needs.materialize.outputs.release_sha }}
tag: ${{ needs.materialize.outputs.tag }}
version: ${{ needs.materialize.outputs.version }}
steps:
- name: Check out a fresh build workspace
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Install the locked toolchain (mise.toml)
uses: jdx/mise-action@82a612c5ab8bcda7cc5db6b7e81a8e7584c3dc6e # v5.2.3
with:
# Pinned so every run, release jobs included, installs the same mise;
# the action still verifies it against mise's signed checksums.
version: "2026.10.18"
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: "1.3.4"
- name: Download the immutable release source
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.materialize.outputs.source_artifact_name }}
- name: Download isolated Hermes evidence
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: hermes-evidence-${{ needs.materialize.outputs.release_sha }}
- name: Restore and verify the exact release source
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
sha256sum --check release-source.sha256
git bundle verify release-source.bundle
git fetch release-source.bundle \
refs/heads/release-candidate:refs/heads/release-candidate \
"refs/tags/$TAG:refs/tags/$TAG"
git checkout --detach "$RELEASE_SHA"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
grep -Eq '^[0-9a-f]{40}$' hermes-source-sha.txt
- name: Build the exact release SHA once and validate metadata
env:
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
mise run build
mise run check-dist
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
- name: Create and verify the tested artifact manifest
env:
PREVIOUS_VERSION: ${{ needs.materialize.outputs.previous_version }}
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
VERSION: ${{ needs.materialize.outputs.version }}
run: |
uv run python scripts/release_contract.py create-manifest \
--previous-version "$PREVIOUS_VERSION" \
--version "$VERSION" \
--tag "$TAG" \
--source-sha "$RELEASE_SHA" \
--hermes-source-sha "$(cat hermes-source-sha.txt)" \
--workflow "release.yml" \
--run-id "${{ github.run_id }}" \
--run-attempt "${{ github.run_attempt }}" \
--artifact-dir dist \
--output release-manifest.json
uv run python scripts/release_contract.py verify-manifest \
--receipt release-manifest.json \
--artifact-dir dist
- name: Bundle the tested immutable artifacts without rebuilding
run: |
sha256sum release-source.bundle release-manifest.json dist/* \
> release-payload.sha256
- name: Stage and read back the exact payload in private GHCR
id: stage
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in private-artifacts}"
python scripts/private_release.py check-private \
--repository ghcr.io/offendingcommit/hermes-plugin-kit
python scripts/private_release.py stage \
--repository ghcr.io/offendingcommit/hermes-plugin-kit \
--tag "candidate-${{ github.run_id }}-$RELEASE_SHA" \
--manifest release-manifest.json \
--artifact-dir dist \
--source-bundle release-source.bundle \
--payload-checksums release-payload.sha256 \
--output staged-release.json
reference="$(jq -er '.bundle_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' staged-release.json)"
echo "bundle_reference=$reference" >> "$GITHUB_OUTPUT"
promote-source:
needs: [materialize, build, immutable-release-control]
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
environment: source-promotion
permissions:
contents: read
outputs:
bundle_reference: ${{ needs.build.outputs.bundle_reference }}
release_sha: ${{ needs.materialize.outputs.release_sha }}
tag: ${{ needs.materialize.outputs.tag }}
version: ${{ needs.materialize.outputs.version }}
steps:
- name: Check out the guarded parent revision without credentials
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: "1.3.4"
- name: Fetch the privately staged payload by immutable digest
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
BUNDLE_REFERENCE: ${{ needs.build.outputs.bundle_reference }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in source-promotion}"
python scripts/private_release.py fetch \
--reference "$BUNDLE_REFERENCE" \
--output-dir .
- name: Validate and atomically push only the tested source
env:
GH_TOKEN: ${{ secrets.SOURCE_PROMOTION_TOKEN }}
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
TAG: ${{ needs.materialize.outputs.tag }}
TRIGGER_SHA: ${{ github.sha }}
run: |
: "${GH_TOKEN:?SOURCE_PROMOTION_TOKEN must be configured in source-promotion}"
sha256sum --check release-payload.sha256
git bundle verify release-source.bundle
git fetch release-source.bundle \
refs/heads/release-candidate:refs/heads/release-candidate \
"refs/tags/$TAG:refs/tags/$TAG"
test "$(git rev-parse refs/heads/release-candidate)" = "$RELEASE_SHA"
test "$(git rev-parse "$RELEASE_SHA^")" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
unexpected="$(git diff --name-only "$TRIGGER_SHA" "$RELEASE_SHA" | grep -Ev '^(CHANGELOG\.md|pyproject\.toml|uv\.lock)$' || true)"
test -z "$unexpected"
remote_tag_sha() {
sha="$(git ls-remote origin "refs/tags/$TAG^{}" | cut -f1)"
if [ -z "$sha" ]; then
sha="$(git ls-remote origin "refs/tags/$TAG" | cut -f1)"
fi
printf '%s' "$sha"
}
remote_main="$(git ls-remote origin refs/heads/main | cut -f1)"
remote_tag="$(remote_tag_sha)"
if [ "$remote_main" = "$RELEASE_SHA" ] && [ "$remote_tag" = "$RELEASE_SHA" ]; then
echo "Source and tag already match the tested release; resuming publication."
elif [ "$remote_main" = "$TRIGGER_SHA" ] && [ -z "$remote_tag" ]; then
gh auth setup-git
if ! git push --atomic origin \
"$RELEASE_SHA:refs/heads/main" \
"refs/tags/$TAG:refs/tags/$TAG"; then
echo "Source push returned an error; verifying remote refs before failing." >&2
fi
else
echo "Remote refs do not match the releasable parent or exact tested release." >&2
exit 1
fi
remote_main="$(git ls-remote origin refs/heads/main | cut -f1)"
remote_tag="$(remote_tag_sha)"
test "$remote_main" = "$RELEASE_SHA"
test "$remote_tag" = "$RELEASE_SHA"
publish-private:
needs: promote-source
runs-on: ubuntu-latest
environment: private-artifacts
permissions:
contents: read
outputs:
bundle_reference: ${{ steps.publish.outputs.bundle_reference }}
receipt_reference: ${{ steps.publish.outputs.receipt_reference }}
steps:
- name: Check out the promoted source identity without credentials
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ needs.promote-source.outputs.release_sha }}
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: "1.3.4"
- name: Publish the exact staged manifest and a private verified receipt
id: publish
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
BUNDLE_REFERENCE: ${{ needs.promote-source.outputs.bundle_reference }}
RELEASE_SHA: ${{ needs.promote-source.outputs.release_sha }}
TAG: ${{ needs.promote-source.outputs.tag }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in private-artifacts}"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
python scripts/private_release.py check-private \
--repository ghcr.io/offendingcommit/hermes-plugin-kit
python scripts/private_release.py publish \
--reference "$BUNDLE_REFERENCE" \
--output release-receipt.json \
--references publication.json
python scripts/release_contract.py verify-final-receipt \
--receipt release-receipt.json
bundle_reference="$(jq -er '.bundle_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' publication.json)"
receipt_reference="$(jq -er '.receipt_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' publication.json)"
test "$bundle_reference" = "$BUNDLE_REFERENCE"
{
echo "bundle_reference=$bundle_reference"
echo "receipt_reference=$receipt_reference"
} >> "$GITHUB_OUTPUT"
github-release:
needs: [promote-source, publish-private]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create or verify an immutable metadata-only GitHub Release
env:
GH_TOKEN: ${{ github.token }}
BUNDLE_REFERENCE: ${{ needs.publish-private.outputs.bundle_reference }}
RECEIPT_REFERENCE: ${{ needs.publish-private.outputs.receipt_reference }}
RELEASE_SHA: ${{ needs.promote-source.outputs.release_sha }}
TAG: ${{ needs.promote-source.outputs.tag }}
VERSION: ${{ needs.promote-source.outputs.version }}
run: |
repository_url="https://github.com/$GITHUB_REPOSITORY.git"
remote_tag="$(git ls-remote "$repository_url" "refs/tags/$TAG^{}" | cut -f1)"
if [ -z "$remote_tag" ]; then
remote_tag="$(git ls-remote "$repository_url" "refs/tags/$TAG" | cut -f1)"
fi
test "$remote_tag" = "$RELEASE_SHA"
jq -en --arg bundle "$BUNDLE_REFERENCE" --arg receipt "$RECEIPT_REFERENCE" \
'[$bundle, $receipt] | all(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))'
body="$(printf '%s\n' \
'Release artifacts are private; authenticated package access is required.' \
'' \
"Bundle: \`$BUNDLE_REFERENCE\`" \
"Receipt: \`$RECEIPT_REFERENCE\`" \
'' \
'Pin these immutable digests, not discovery tags. See README installation instructions.')"
if ! gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \
--json isImmutable,isDraft,tagName,body,assets > existing-release.json; then
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--verify-tag \
--title "hermes-plugin-kit $VERSION" \
--notes "$body"
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \
--json isImmutable,isDraft,tagName,body,assets > existing-release.json
fi
jq -e --arg tag "$TAG" --arg body "$body" \
'.isImmutable == true and .isDraft == false and .tagName == $tag
and .body == $body and .assets == []' existing-release.json