Repository navigation
708 lines (641 loc) · 26.6 KB
/
Copy pathnode-github-release.yml
File metadata and controls
708 lines (641 loc) · 26.6 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
name: node-github-release
on:
workflow_dispatch:
inputs:
tag:
description: Existing stable npm release tag
required: true
type: string
run_id:
description: Successful node-release run to use for backfill
required: false
type: string
permissions:
contents: read
concurrency:
group: node-github-release
queue: max
jobs:
release:
if: >-
github.repository == 'openai/codex-security' &&
github.ref == 'refs/heads/main'
name: publish verified GitHub release
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
outputs:
version: ${{ steps.release.outputs.version }}
sha: ${{ steps.release.outputs.sha }}
integrity: ${{ steps.artifact.outputs.integrity }}
has-action: ${{ steps.action.outputs.present }}
steps:
- name: Checkout release automation
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: refs/heads/main
- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24.15.0"
registry-url: "https://registry.npmjs.org"
package-manager-cache: false
- name: Install provenance-capable npm
shell: bash
run: |
set -euo pipefail
npm_tools="$RUNNER_TEMP/codex-security-provenance-npm"
npm install \
--prefix "$npm_tools" \
--ignore-scripts \
--no-audit \
--no-fund \
--registry=https://openai.firewall.socket.dev/npm/ \
npm@11.12.1
if [[ "$("$npm_tools/node_modules/.bin/npm" --version)" != "11.12.1" ]]; then
echo "npm 11.12.1 is required to verify Sigstore attestations." >&2
exit 1
fi
printf '%s\n' "$npm_tools/node_modules/.bin" >> "$GITHUB_PATH"
- name: Verify bundled provenance-capable npm
shell: bash
run: |
set -euo pipefail
if [[ "$(npm --version)" != "11.12.1" ]]; then
echo "npm 11.12.1 is required to verify Sigstore attestations." >&2
exit 1
fi
- name: Resolve the successful protected release
id: release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
INPUT_TAG: ${{ inputs.tag }}
INPUT_RUN_ID: ${{ inputs.run_id }}
run: |
set -euo pipefail
release_tag="${INPUT_TAG:-}"
release_run="${INPUT_RUN_ID:-}"
if [[ ! "$release_tag" =~ ^npm-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "GitHub releases require an existing stable npm-vX.Y.Z tag." >&2
exit 1
fi
if ! tag_ref="$(
gh api \
"repos/$GITHUB_REPOSITORY/git/ref/tags/$release_tag" \
--jq '[.object.type, .object.sha] | @tsv'
)"; then
echo "GitHub releases require an existing stable npm-vX.Y.Z tag." >&2
exit 1
fi
IFS=$'\t' read -r tag_type tag_object <<< "$tag_ref"
if [[ ! "$tag_object" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "GitHub releases require a valid Git tag object." >&2
exit 1
fi
case "$tag_type" in
commit)
release_sha="$tag_object"
;;
tag)
if ! release_sha="$(
gh api \
"repos/$GITHUB_REPOSITORY/git/tags/$tag_object" \
--jq 'if .object.type == "commit" then .object.sha else empty end'
)"; then
echo "GitHub releases require a tag pointing to a commit." >&2
exit 1
fi
;;
*)
echo "GitHub releases require a tag pointing to a commit." >&2
exit 1
;;
esac
if [[ ! "$release_sha" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "GitHub releases require a tag pointing to a commit." >&2
exit 1
fi
if [[ -z "$release_run" ]]; then
release_run="$(
gh run list \
--repo "$GITHUB_REPOSITORY" \
--workflow node-release.yml \
--commit "$release_sha" \
--limit 20 \
--json databaseId,status,conclusion \
--jq '[.[] | select(.status == "completed" and .conclusion == "success")] | first | .databaseId // empty'
)"
fi
if [[ ! "$release_run" =~ ^[1-9][0-9]*$ ]]; then
echo "No successful protected npm release exists for $release_tag." >&2
exit 1
fi
for ((attempt = 1; attempt <= 30; attempt++)); do
run_fields="$(
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$release_run" \
--jq '[.name, .status, (.conclusion // "pending"), .head_sha, .head_branch] | @tsv'
)"
IFS=$'\t' read -r run_name run_status run_conclusion run_sha run_tag <<< "$run_fields"
if [[ "$run_name" != "node-release" ||
"$run_sha" != "$release_sha" ||
"$run_tag" != "$release_tag" ]]; then
echo "The release run must successfully publish the exact tagged commit." >&2
exit 1
fi
if [[ "$run_status" == "completed" ]]; then
break
fi
if (( attempt == 30 )); then
echo "Timed out waiting for protected npm release $release_run to complete." >&2
exit 1
fi
sleep 2
done
if [[ "$run_conclusion" != "success" ]]; then
echo "The release run must successfully publish the exact tagged commit." >&2
exit 1
fi
{
printf 'tag=%s\n' "$release_tag"
printf 'version=%s\n' "${release_tag#npm-v}"
printf 'sha=%s\n' "$release_sha"
printf 'run-id=%s\n' "$release_run"
} >> "$GITHUB_OUTPUT"
- name: Wait for the published npm package
shell: bash
env:
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: |
set -euo pipefail
# npm can finish publishing before its registry makes the version available.
for attempt in {1..21}; do
if metadata="$(
npm view "@openai/codex-security@$RELEASE_VERSION" version \
--json --prefer-online --registry=https://registry.npmjs.org/
)"; then
exit 0
fi
printf '%s\n' "$metadata" >&2
if ! printf '%s\n' "$metadata" | node --input-type=module --eval '
import { readFileSync } from "node:fs";
const result = JSON.parse(readFileSync(0, "utf8"));
process.exit(result?.error?.code === "E404" ? 0 : 1);
'; then
exit 1
fi
if (( attempt == 21 )); then
echo "The published npm version did not become available within ten minutes." >&2
exit 1
fi
echo "Waiting for npm publication to become available." >&2
sleep 30
done
- name: Download the verified or durable npm release artifact
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_RUN_ID: ${{ steps.release.outputs.run-id }}
RELEASE_VERSION: ${{ steps.release.outputs.version }}
run: |
set -euo pipefail
mkdir -p dist
if ! gh run download "$RELEASE_RUN_ID" \
--repo "$GITHUB_REPOSITORY" \
--name npm-release-tarball \
--dir dist; then
echo "Release artifact expired; retrieving the public npm tarball."
npm pack "@openai/codex-security@$RELEASE_VERSION" \
--ignore-scripts \
--pack-destination dist \
--registry=https://registry.npmjs.org/
fi
- name: Verify the public npm package and signed provenance
id: artifact
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_RUN_ID: ${{ steps.release.outputs.run-id }}
RELEASE_VERSION: ${{ steps.release.outputs.version }}
RELEASE_SHA: ${{ steps.release.outputs.sha }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
set -euo pipefail
shopt -s nullglob
archives=(dist/*.tgz)
if (( ${#archives[@]} != 1 )); then
echo "Expected exactly one verified npm release tarball." >&2
exit 1
fi
archive="${archives[0]}"
metadata="$(
npm view "@openai/codex-security@$RELEASE_VERSION" \
name version gitHead dist.integrity dist.attestations \
--json \
--registry=https://registry.npmjs.org/
)"
consumer="$(mktemp -d)"
trap 'rm -rf "$consumer"' EXIT
npm install \
--prefix "$consumer" \
--ignore-scripts \
--omit=optional \
--no-audit \
--no-fund \
--registry=https://registry.npmjs.org/ \
"@openai/codex-security@$RELEASE_VERSION"
signature_report="$(
npm audit signatures \
--prefix "$consumer" \
--registry=https://registry.npmjs.org/ \
--json \
--include-attestations
)"
if verified_provenance="$(
printf '%s\n' "$signature_report" |
node sdk/typescript/scripts/release-automation.mjs \
verify-provenance \
"$archive" \
"$RELEASE_VERSION" \
"$RELEASE_SHA" \
"$GITHUB_REPOSITORY" \
"$RELEASE_RUN_ID"
)"; then
verified_run_id="$RELEASE_RUN_ID"
printf '%s\n' "$verified_provenance"
echo "Verified npm provenance for the resolved release run."
else
recovery_conclusion="$(
gh api \
"repos/$GITHUB_REPOSITORY/actions/runs/$RELEASE_RUN_ID/jobs?per_page=100" \
--paginate \
--jq '.jobs[] | select(.name == "publish") | .steps[] | select(.name == "Verify recovered npm release provenance") | .conclusion'
)"
if [[ "$recovery_conclusion" != "success" ]]; then
echo "Signed npm provenance must identify the resolved successful release run." >&2
exit 1
fi
verified_provenance="$(
printf '%s\n' "$signature_report" |
node sdk/typescript/scripts/release-automation.mjs \
verify-recovered-provenance \
"$archive" \
"$RELEASE_VERSION" \
"$RELEASE_SHA" \
"$GITHUB_REPOSITORY"
)"
original_run_id="$(
printf '%s\n' "$verified_provenance" |
node --input-type=module --eval '
import { readFileSync } from "node:fs";
const provenance = JSON.parse(readFileSync(0, "utf8"));
if (!/^[1-9][0-9]*$/.test(provenance.runId)) {
throw new Error("The signing run must be a valid workflow run.");
}
process.stdout.write(provenance.runId);
'
)"
original_run_fields="$(
gh api \
"repos/$GITHUB_REPOSITORY/actions/runs/$original_run_id" \
--jq '[.name, .status, .head_sha, .head_branch] | @tsv'
)"
IFS=$'\t' read -r original_name original_status original_sha original_tag <<< "$original_run_fields"
if [[ "$original_name" != "node-release" ||
"$original_status" != "completed" ||
"$original_sha" != "$RELEASE_SHA" ||
"$original_tag" != "$RELEASE_TAG" ]]; then
echo "Recovered npm provenance must identify the exact protected release." >&2
exit 1
fi
verified_run_id="$original_run_id"
printf '%s\n' "$verified_provenance"
echo "Verified protected recovery provenance from its original signing run."
fi
printf '%s\n' "$metadata" |
CODEX_SECURITY_VERIFIED_PROVENANCE="$verified_provenance" \
node sdk/typescript/scripts/release-automation.mjs \
verify-github-publication \
"$archive" \
"$RELEASE_VERSION" \
"$RELEASE_SHA" \
"$GITHUB_REPOSITORY" \
"$verified_run_id"
printf 'archive=%s\n' "$archive" >> "$GITHUB_OUTPUT"
printf 'integrity=%s\n' "$(jq -r '."dist.integrity" // .dist.integrity' <<< "$metadata")" >> "$GITHUB_OUTPUT"
- name: Detect Action release source
id: action
env:
RELEASE_SHA: ${{ steps.release.outputs.sha }}
run: |
if git cat-file -e "$RELEASE_SHA:action.yml" 2>/dev/null; then
echo 'present=true' >> "$GITHUB_OUTPUT"
fi
- name: Resolve published release history
id: history
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
RELEASE_SHA: ${{ steps.release.outputs.sha }}
run: |
set -euo pipefail
published_versions="$(
npm view @openai/codex-security versions \
--json \
--registry=https://registry.npmjs.org/
)"
published_github_tags="$(
gh api --paginate \
"repos/$GITHUB_REPOSITORY/releases?per_page=100" \
--jq '.[] | select(.draft == false and .prerelease == false) | .tag_name'
)"
reachable_tags=""
if git rev-parse "$RELEASE_SHA^" >/dev/null 2>&1; then
reachable_tags="$(
git tag --merged "$RELEASE_SHA^" \
--list 'npm-v*' \
--sort=-version:refname
)"
fi
history="$(
CODEX_SECURITY_PUBLISHED_NPM_VERSIONS="$published_versions" \
CODEX_SECURITY_PUBLISHED_GITHUB_TAGS="$published_github_tags" \
CODEX_SECURITY_REACHABLE_RELEASE_TAGS="$reachable_tags" \
node sdk/typescript/scripts/release-automation.mjs \
release-history "$RELEASE_TAG"
)"
previous_tag="$(
printf '%s\n' "$history" |
node --input-type=module --eval '
import { readFileSync } from "node:fs";
const history = JSON.parse(readFileSync(0, "utf8"));
process.stdout.write(history.previousTag ?? "");
'
)"
make_latest="$(
printf '%s\n' "$history" |
node --input-type=module --eval '
import { readFileSync } from "node:fs";
const history = JSON.parse(readFileSync(0, "utf8"));
if (typeof history.makeLatest !== "boolean") {
throw new Error("Release latest status must be explicit.");
}
process.stdout.write(String(history.makeLatest));
'
)"
{
printf 'previous-tag=%s\n' "$previous_tag"
printf 'make-latest=%s\n' "$make_latest"
} >> "$GITHUB_OUTPUT"
- name: Publish GitHub Release and generated notes
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
RELEASE_VERSION: ${{ steps.release.outputs.version }}
RELEASE_SHA: ${{ steps.release.outputs.sha }}
RELEASE_ARCHIVE: ${{ steps.artifact.outputs.archive }}
PREVIOUS_TAG: ${{ steps.history.outputs.previous-tag }}
MAKE_LATEST: ${{ steps.history.outputs.make-latest }}
run: |
set -euo pipefail
release_workspace="$(mktemp -d)"
trap 'rm -rf "$release_workspace"' EXIT
node --input-type=module --eval '
import { publishGitHubRelease } from "./sdk/typescript/scripts/publish-github-release.mjs";
try {
publishGitHubRelease(process.env, process.argv[1]);
} catch (error) {
if (error.status === undefined) throw error;
process.exit(error.status);
}
' "$release_workspace"
installed:
name: verify published installation
needs: release
uses: ./.github/workflows/published-install-smoke.yml
with:
version: ${{ needs.release.outputs.version }}
# Use current checks when recovering releases that predate exact-version smoke.
ref: ${{ github.sha }}
action-verify:
name: verify matching Action
needs: [release, installed]
if: needs.release.outputs.has-action == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
outputs:
runtime-lock-artifact: ${{ steps.runtime-lock.outputs.artifact-id }}
env:
RELEASE_VERSION: ${{ needs.release.outputs.version }}
RELEASE_SHA: ${{ needs.release.outputs.sha }}
CLI_INTEGRITY: ${{ needs.release.outputs.integrity }}
steps:
- &action-checkout-automation
name: Checkout release automation
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
path: automation
persist-credentials: false
- &action-checkout-source
name: Checkout verified CLI source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.release.outputs.sha }}
path: release-source
fetch-depth: 0
persist-credentials: false
- &action-setup-node
name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
- name: Set up Socket Firewall
uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
with:
mode: firewall-free
firewall-version: "1.15.0"
- name: Set up the Ubuntu sandbox
run: |
sudo apt-get update
sudo apt-get install --yes bubblewrap apparmor-profiles
sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict
- &action-reuse-distribution
name: Reuse an existing immutable Action distribution
id: distribution
working-directory: release-source
shell: bash
run: |
set -euo pipefail
action_tag="action-v$RELEASE_VERSION"
if git show-ref --verify --quiet "refs/tags/$action_tag"; then
action_sha="$(git rev-parse "$action_tag^{commit}")"
if [[ "$(git rev-parse "$action_sha^")" != "$RELEASE_SHA" ]]; then
echo 'The existing Action tag must derive from the exact CLI source.' >&2
exit 1
fi
changed_source="$(git diff --name-only "$RELEASE_SHA" "$action_sha" -- . \
':!github-action/package.json' ':!github-action/package-lock.json' \
':!github-action/runtime/package.json' ':!github-action/runtime/package-lock.json' \
':!github-action/dist/index.cjs' ':!github-action/dist/post.cjs')"
if [[ -n "$changed_source" ]]; then
echo 'The existing Action tag contains changes outside release packaging.' >&2
exit 1
fi
git checkout --detach "$action_sha"
node "$GITHUB_WORKSPACE/automation/github-action/scripts/release.mjs" verify \
"$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \
"$GITHUB_WORKSPACE/release-source/github-action"
echo 'existing=true' >> "$GITHUB_OUTPUT"
fi
- name: Resolve the verified CLI runtime lock
if: steps.distribution.outputs.existing != 'true'
run: |
node automation/github-action/scripts/release.mjs prepare \
"$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \
"$GITHUB_WORKSPACE/release-source/github-action"
- name: Install Action and CLI dependencies
working-directory: release-source/github-action
run: |
npm ci --ignore-scripts --no-audit --no-fund
runtime_cache="$(mktemp -d "$RUNNER_TEMP/action-runtime-firewall-cache.XXXXXX")"
trap 'rm -rf "$runtime_cache"' EXIT
sfw npm ci --prefix runtime --ignore-scripts --include=optional --no-audit --no-fund \
--registry=https://registry.npmjs.org/ --cache="$runtime_cache"
- name: Build Action distribution
if: steps.distribution.outputs.existing != 'true'
working-directory: release-source/github-action
run: npm run build
- name: Validate the packaged Action
working-directory: release-source/github-action
run: |
npm run validate
npm run test:cli
node scripts/linux-smoke.mjs
npm audit --audit-level=high
npm audit --prefix runtime --omit=dev --audit-level=high
npm run check-dist
- name: Save verified CLI runtime lock
id: runtime-lock
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: action-runtime-lock
path: release-source/github-action/runtime/package-lock.json
if-no-files-found: error
retention-days: 7
action:
name: publish matching Action
needs: [release, action-verify]
if: needs.release.outputs.has-action == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: write
env:
RELEASE_VERSION: ${{ needs.release.outputs.version }}
RELEASE_SHA: ${{ needs.release.outputs.sha }}
CLI_INTEGRITY: ${{ needs.release.outputs.integrity }}
steps:
- *action-checkout-automation
- *action-checkout-source
- *action-setup-node
- *action-reuse-distribution
- name: Download verified CLI runtime lock
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
artifact-ids: ${{ needs.action-verify.outputs.runtime-lock-artifact }}
path: ${{ runner.temp }}/action-runtime-lock
merge-multiple: true
- name: Stage verified CLI runtime lock
run: |
node automation/github-action/scripts/release.mjs stage \
"$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" \
"$RUNNER_TEMP/action-runtime-lock/package-lock.json" \
"$GITHUB_WORKSPACE/release-source/github-action"
# Rebuild from reviewed source in a fresh job; never run the CLI here.
- name: Install Action build dependencies
working-directory: release-source/github-action
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Build Action distribution
if: steps.distribution.outputs.existing != 'true'
working-directory: release-source/github-action
run: npm run build
- name: Check Action distribution before publication
working-directory: release-source/github-action
run: npm run check-dist
- name: Commit and verify release metadata
working-directory: release-source
env:
EXISTING: ${{ steps.distribution.outputs.existing }}
run: |
set -euo pipefail
if [[ "$EXISTING" != true ]]; then
git add github-action/package.json github-action/package-lock.json \
github-action/runtime/package.json github-action/runtime/package-lock.json \
github-action/dist/index.cjs github-action/dist/post.cjs
git -c user.name='github-actions[bot]' \
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
-c commit.gpgsign=false commit --allow-empty -m "chore(release): package Action $RELEASE_VERSION"
fi
node "$GITHUB_WORKSPACE/automation/github-action/scripts/release.mjs" metadata \
"$RELEASE_VERSION" "$RELEASE_SHA" "$CLI_INTEGRITY" "$(git rev-parse HEAD)" \
"$GITHUB_WORKSPACE/release-source/github-action"
- name: Publish immutable Action tag and metadata
working-directory: release-source
env:
GH_TOKEN: ${{ github.token }}
EXISTING: ${{ steps.distribution.outputs.existing }}
run: |
set -euo pipefail
if [[ "$EXISTING" != true ]]; then
git -c credential.helper= -c 'credential.helper=!gh auth git-credential' \
push origin "HEAD:refs/tags/action-v$RELEASE_VERSION"
fi
cp github-action/build/release-manifest.json "$RUNNER_TEMP/action-release-manifest.json"
cp github-action/build/sbom.cdx.json "$RUNNER_TEMP/action-sbom.cdx.json"
existing_assets="$(gh release view "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name')"
comparison="$(mktemp -d)"
trap 'rm -rf "$comparison"' EXIT
for asset in action-release-manifest.json action-sbom.cdx.json; do
if grep -Fxq "$asset" <<< "$existing_assets"; then
gh release download "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" \
--pattern "$asset" --dir "$comparison"
if ! cmp "$RUNNER_TEMP/$asset" "$comparison/$asset"; then
echo "Published Action metadata differs: $asset" >&2
exit 1
fi
else
gh release upload "npm-v$RELEASE_VERSION" --repo "$GITHUB_REPOSITORY" "$RUNNER_TEMP/$asset"
fi
done
{
printf '### Codex Security %s\n\n' "$RELEASE_VERSION"
printf 'CLI source: `%s`\n\n' "$RELEASE_SHA"
printf 'Action: `uses: %s@%s` (`action-v%s`)\n' "$GITHUB_REPOSITORY" "$(git rev-parse HEAD)" "$RELEASE_VERSION"
} >> "$GITHUB_STEP_SUMMARY"
complete:
name: release status
if: always()
needs: [release, installed, action]
runs-on: ubuntu-latest
steps:
- name: Require completed release channels
env:
RELEASE_RESULT: ${{ needs.release.result }}
INSTALL_RESULT: ${{ needs.installed.result }}
ACTION_RESULT: ${{ needs.action.result }}
HAS_ACTION: ${{ needs.release.outputs.has-action }}
run: |
test "$RELEASE_RESULT" = success
test "$INSTALL_RESULT" = success
if [[ "$HAS_ACTION" == true ]]; then
test "$ACTION_RESULT" = success
fi