Repository navigation
392 lines (386 loc) · 18.8 KB
/
Copy pathrelease-github.yml
File metadata and controls
392 lines (386 loc) · 18.8 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
name: Publish GitHub Release
on:
workflow_run:
workflows:
- Release npm packages
types:
- completed
workflow_dispatch:
inputs:
release_tag:
description: Immutable signed release tag (vX.Y.Z)
required: true
type: string
source_run_id:
description: Source Release npm packages workflow run ID
required: true
type: string
source_run_attempt:
description: Exact source Release npm packages workflow run attempt
required: true
type: string
permissions:
contents: read
concurrency:
group: release-github-${{ github.event.workflow_run.head_branch || inputs.release_tag }}
cancel-in-progress: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
verify-release:
name: Verify and assemble the GitHub Release
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
# Everything that decides what to publish runs here, read-only. Only
# publish-release below can change the repository.
permissions:
actions: read
contents: read
outputs:
release_tag: ${{ steps.source.outputs.release_tag }}
npm_version: ${{ steps.source.outputs.npm_version }}
head_sha: ${{ steps.source.outputs.head_sha }}
tag_object_sha: ${{ steps.source.outputs.tag_object_sha }}
release_record: ${{ steps.contract.outputs.release_record }}
steps:
- name: Refuse non-default-branch manual recovery
if: ${{ github.event_name == 'workflow_dispatch' && github.ref_name != github.event.repository.default_branch }}
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
echo "::error::GitHub release recovery must run from the default branch code ($DEFAULT_BRANCH)."
exit 1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
- name: Verify release source run and signed tag
id: source
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.event.workflow_run.head_branch || inputs.release_tag }}
SOURCE_RUN_ID: ${{ github.event.workflow_run.id || inputs.source_run_id }}
SOURCE_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt || inputs.source_run_attempt }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs verify-source-run \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--source-run-id "$SOURCE_RUN_ID" \
--source-run-attempt "$SOURCE_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
- name: Verify npm provenance for every published package
env:
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
NPM_VERSION: ${{ steps.source.outputs.npm_version }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
SOURCE_RUN_ID: ${{ steps.source.outputs.source_run_id }}
SOURCE_RUN_ATTEMPT: ${{ steps.source.outputs.source_run_attempt }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs verify-npm-provenance \
--release-tag "$RELEASE_TAG" \
--npm-version "$NPM_VERSION" \
--head-sha "$HEAD_SHA" \
--source-run-id "$SOURCE_RUN_ID" \
--source-run-attempt "$SOURCE_RUN_ATTEMPT" \
--output github-release-evidence/npm-provenance.json
- name: Cryptographically verify npm registry signatures
env:
NPM_VERSION: ${{ steps.source.outputs.npm_version }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs verify-npm-signatures \
--npm-version "$NPM_VERSION" \
--audit-dir github-release-npm-audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
ref: ${{ steps.source.outputs.head_sha }}
path: github-release-protocol-source
# Tags whose source carries the receipt builder publish the full release
# record (SBOM, receipt, attestations, immutable publication). Recovery
# of an older tag keeps that tag's original asset contract.
- name: Detect the release record contract
id: contract
run: |
if [[ -f github-release-protocol-source/scripts/release-receipt.mjs ]]; then
echo "release_record=true" >> "$GITHUB_OUTPUT"
else
echo "release_record=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ steps.source.outputs.source_run_id }}
name: coven-macos
path: github-release-source/coven-macos
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ steps.source.outputs.source_run_id }}
name: coven-macos-x64
path: github-release-source/coven-macos-x64
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ steps.source.outputs.source_run_id }}
name: coven-linux-x64
path: github-release-source/coven-linux-x64
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ steps.source.outputs.source_run_id }}
name: coven-windows
path: github-release-source/coven-windows
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
if: ${{ steps.contract.outputs.release_record == 'true' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ steps.source.outputs.source_run_id }}
name: coven-release-publication-authorization-${{ steps.source.outputs.release_tag }}
path: github-release-evidence/authorization
- name: Reconfirm source run attempt after artifact download
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
SOURCE_RUN_ID: ${{ steps.source.outputs.source_run_id }}
SOURCE_RUN_ATTEMPT: ${{ steps.source.outputs.source_run_attempt }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs verify-source-run-attempt \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--source-run-id "$SOURCE_RUN_ID" \
--source-run-attempt "$SOURCE_RUN_ATTEMPT"
- name: Package deterministic GitHub release assets
env:
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
SOURCE_DATE_EPOCH: ${{ steps.source.outputs.source_date_epoch }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
run: |
set -euo pipefail
PROTOCOL_ARGS=()
if [[ -f github-release-protocol-source/scripts/package-automations-protocol.mjs ]]; then
SOURCE_COMMIT="$HEAD_SHA" \
node github-release-protocol-source/scripts/package-automations-protocol.mjs \
--output github-release-protocol
PROTOCOL_BUNDLE="$PWD/github-release-protocol/coven-automations-v1-contract-${HEAD_SHA}.tar.gz"
PROTOCOL_SHA256="$(sha256sum "$PROTOCOL_BUNDLE" | awk '{print $1}')"
node scripts/package-automations-protocol.mjs verify \
--bundle "$PROTOCOL_BUNDLE" \
--source-commit "$HEAD_SHA" \
--sha256 "$PROTOCOL_SHA256"
SOURCE_COMMIT="$HEAD_SHA" \
node github-release-protocol-source/scripts/package-automations-authority-profile.mjs \
--output github-release-authority-profile
AUTHORITY_PROFILE_BUNDLE="$PWD/github-release-authority-profile/coven-automations-authority-v1-contract-${HEAD_SHA}.tar.gz"
AUTHORITY_PROFILE_SHA256="$(sha256sum "$AUTHORITY_PROFILE_BUNDLE" | awk '{print $1}')"
node scripts/package-automations-authority-profile.mjs verify \
--bundle "$AUTHORITY_PROFILE_BUNDLE" \
--source-commit "$HEAD_SHA" \
--sha256 "$AUTHORITY_PROFILE_SHA256"
PROTOCOL_ARGS=(
--source-commit "$HEAD_SHA"
--protocol-bundle "$PROTOCOL_BUNDLE"
--authority-profile-bundle "$AUTHORITY_PROFILE_BUNDLE"
)
fi
node scripts/package-github-release.mjs package \
--release-tag "$RELEASE_TAG" \
--artifacts-dir github-release-source \
--output-dir github-release-assets \
--source-date-epoch "$SOURCE_DATE_EPOCH" \
"${PROTOCOL_ARGS[@]}"
- name: Re-verify the signed tag before GitHub publication
if: ${{ steps.contract.outputs.release_record == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
TAG_OBJECT_SHA: ${{ steps.source.outputs.tag_object_sha }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
run: |
set -euo pipefail
node scripts/verify-release-tag.mjs \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--output github-release-evidence/tag-verification.json > github-release-evidence/tag-verification.env
grep -qx "head_sha=$HEAD_SHA" github-release-evidence/tag-verification.env
grep -qx "tag_object_sha=$TAG_OBJECT_SHA" github-release-evidence/tag-verification.env
- name: Re-check exact-source CI before GitHub publication
if: ${{ steps.contract.outputs.release_record == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
TAG_OBJECT_SHA: ${{ steps.source.outputs.tag_object_sha }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs verify-source-acceptance \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--head-sha "$HEAD_SHA" \
--tag-object-sha "$TAG_OBJECT_SHA" \
--output github-release-evidence/source-acceptance.json
- name: Check release governance before GitHub publication
if: ${{ steps.contract.outputs.release_record == 'true' }}
env:
RELEASE_GOVERNANCE_READ_TOKEN: ${{ secrets.RELEASE_GOVERNANCE_READ_TOKEN }}
run: |
set -euo pipefail
node scripts/release-governance.mjs check \
--repository "$GITHUB_REPOSITORY" \
--policy github-release-protocol-source/.github/release-governance.json \
--snapshot-output github-release-evidence/governance-snapshot.json \
--output github-release-evidence/governance-evaluation.json
- name: Build the release SBOM from the tagged source
if: ${{ steps.contract.outputs.release_record == 'true' }}
env:
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
SOURCE_DATE_EPOCH: ${{ steps.source.outputs.source_date_epoch }}
run: |
set -euo pipefail
node scripts/release-dependency-inventory.mjs \
--release-tag "$RELEASE_TAG" \
--source-commit "$HEAD_SHA" \
--source-date-epoch "$SOURCE_DATE_EPOCH" \
--source-dir github-release-protocol-source \
--output-dir github-release-assets
- name: Build the release receipt
if: ${{ steps.contract.outputs.release_record == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.source.outputs.release_tag }}
HEAD_SHA: ${{ steps.source.outputs.head_sha }}
SOURCE_RUN_ID: ${{ steps.source.outputs.source_run_id }}
SOURCE_RUN_ATTEMPT: ${{ steps.source.outputs.source_run_attempt }}
TRIGGER: ${{ github.event_name }}
run: |
set -euo pipefail
node scripts/release-receipt.mjs build \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--trigger "$TRIGGER" \
--source-run-id "$SOURCE_RUN_ID" \
--source-run-attempt "$SOURCE_RUN_ATTEMPT" \
--source-run-head-sha "$HEAD_SHA" \
--support-policy github-release-protocol-source/.github/release-support.json \
--tag-verification github-release-evidence/tag-verification.json \
--source-acceptance github-release-evidence/source-acceptance.json \
--publication-authorization github-release-evidence/authorization/release-publication-authorization.json \
--governance-evaluation github-release-evidence/governance-evaluation.json \
--npm-provenance github-release-evidence/npm-provenance.json \
--assets-dir github-release-assets
- name: Hand the verified assets to the publish job
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coven-github-release-assets-${{ steps.source.outputs.release_tag }}
path: github-release-assets/
if-no-files-found: error
- name: Retain verification evidence
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coven-github-release-evidence-${{ steps.source.outputs.release_tag || 'unverified' }}
path: github-release-evidence/
if-no-files-found: warn
publish-release:
name: Publish GitHub Release assets
needs: verify-release
runs-on: ubuntu-latest
# The same group as the npm publication job: one channel mutation at a time.
concurrency:
group: coven-release-channel
cancel-in-progress: false
# contents:write publishes the release; id-token and attestations sign the
# asset provenance and the reconciliation record. Nothing here publishes npm.
permissions:
attestations: write
contents: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.repository.default_branch }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .node-version
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: coven-github-release-assets-${{ needs.verify-release.outputs.release_tag }}
path: github-release-assets
- name: Attest every release asset
if: ${{ needs.verify-release.outputs.release_record == 'true' }}
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: github-release-assets/*
- name: Synchronize canonical GitHub release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.verify-release.outputs.release_tag }}
TAG_OBJECT_SHA: ${{ needs.verify-release.outputs.tag_object_sha }}
HEAD_SHA: ${{ needs.verify-release.outputs.head_sha }}
RELEASE_RECORD: ${{ needs.verify-release.outputs.release_record }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs sync-release \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--output-dir github-release-assets \
--expected-tag-object-sha "$TAG_OBJECT_SHA" \
--expected-head-sha "$HEAD_SHA" \
--release-record "$RELEASE_RECORD"
- name: Publish the verified draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.verify-release.outputs.release_tag }}
TAG_OBJECT_SHA: ${{ needs.verify-release.outputs.tag_object_sha }}
HEAD_SHA: ${{ needs.verify-release.outputs.head_sha }}
RELEASE_RECORD: ${{ needs.verify-release.outputs.release_record }}
run: |
set -euo pipefail
node scripts/package-github-release.mjs publish-release \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--output-dir github-release-assets \
--expected-tag-object-sha "$TAG_OBJECT_SHA" \
--expected-head-sha "$HEAD_SHA" \
--release-record "$RELEASE_RECORD" \
--require-immutable "$RELEASE_RECORD" \
--output github-release-publication/publication.json
- name: Reconcile every channel with the receipt
if: ${{ needs.verify-release.outputs.release_record == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.verify-release.outputs.release_tag }}
NPM_VERSION: ${{ needs.verify-release.outputs.npm_version }}
run: |
set -euo pipefail
node scripts/release-receipt.mjs reconcile \
--repository "$GITHUB_REPOSITORY" \
--release-tag "$RELEASE_TAG" \
--support-policy .github/release-support.json \
--receipt "github-release-assets/coven-v${NPM_VERSION}-release-receipt.json" \
--output github-release-publication/reconciliation.json
- name: Attest the reconciliation against the receipt
if: ${{ needs.verify-release.outputs.release_record == 'true' }}
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: github-release-assets/coven-v${{ needs.verify-release.outputs.npm_version }}-release-receipt.json
predicate-type: https://opencoven.ai/attestations/release-reconciliation/v1
predicate-path: github-release-publication/reconciliation.json
- name: Retain the publication record
if: ${{ always() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coven-github-release-publication-${{ needs.verify-release.outputs.release_tag }}
path: github-release-publication/
if-no-files-found: warn