-
Notifications
You must be signed in to change notification settings - Fork 5
446 lines (382 loc) · 15.2 KB
/
publish.yml
File metadata and controls
446 lines (382 loc) · 15.2 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
name: Publish Package
on:
workflow_dispatch: {}
push:
branches:
- release-v*
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
attestations: write
actions: write
id-token: write
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
jobs:
provenance:
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_nodejs_slsa3.yml@f7dd8c54c2067bafc12ca7a55595d5ee9b75204a # v2.1.0
with:
run-scripts: 'install-pnpm, install-deps, style, nx-build-skip-cache, nx-test-skip-cache, generate'
node-version: '22.14.0'
rekor-log-public: true
harden-runner:
needs: [provenance]
name: Harden runner
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- name: Download Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
start:
needs: state
name: Start new release candidate
permissions:
contents: write
actions: write
pull-requests: write
if: needs.state.outputs.start == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Checkout Repo
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- run: bash scripts/start.sh
shell: bash
- name: Commit changes
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
with:
commit-message: '🤖 chore: Push the release candidate change'
title: 'chore: 🤖 [Automated PR] Push the release candidate change'
token: ${{ steps.gh-app-token.outputs.token }}
sign-commits: true
body: |
This PR adds the RC changes
- name: Start Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ vars.SLACK_CHANNEL }}
if: always()
state:
name: Check state
permissions:
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Checkout Repo
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- id: state
name: Get state
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
with:
result-encoding: string
script: await require('./scripts/state.js')({ github, context, core })
- name: State Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()
outputs:
# Job Flags
start: ${{ steps.state.outputs.start }}
changesets: ${{ steps.state.outputs.changesets }}
promote: ${{ steps.state.outputs.promote }}
publish: ${{ steps.state.outputs.publish }}
merge: ${{ steps.state.outputs.merge }}
# Global variables
is_prerelease: ${{ steps.state.outputs.is_prerelease }}
promote:
needs: state
name: Promote to final release
permissions:
contents: write
actions: write
pull-requests: write
if: needs.state.outputs.promote == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Exit prerelease state
if: needs.state.outputs.is_prerelease == 'true'
run: npx changeset pre exit rc
shell: bash
- name: Commit changes
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
with:
commit-message: '🤖 chore: Push changes to exit RC'
title: 'chore: 🤖 [Automated PR] Push changes to exit RC'
token: ${{ steps.gh-app-token.outputs.token }}
sign-commits: true
body: |
This PR pushes changes to exit RC
- name: Promote Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()
changesets:
needs: state
name: Update PR to release
permissions:
contents: write
pull-requests: write
if: needs.state.outputs.changesets == 'true'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
fetch-depth: 0
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Create PR
uses: changesets/action@3de3850952bec538fde60aac71731376e57b9b57 # v1.4.8
env:
GITHUB_TOKEN: ${{ steps.gh-app-token.outputs.token }}
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
with:
version: pnpm ci:version
title: 'ci: update the version packages'
commit: 'ci: update the version packages'
- name: Changesets Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()
publish:
needs: [state, provenance]
name: Publish package to npm
environment: npm
if: needs.state.outputs.publish == 'true' && needs.state.outputs.is_prerelease == 'false'
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- id: tag
name: Tag
run: bash scripts/tag.sh
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
- name: Upload tarball artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ github.ref_name }}
path: ${{ needs.provenance.outputs.package-name }}
- name: Download tarball
uses: slsa-framework/slsa-github-generator/.github/actions/secure-download-artifact@3bcecb4ade4f265cff30488059a9dca39e26b360 # main
with:
name: ${{ needs.provenance.outputs.package-download-name }}
path: ${{ needs.provenance.outputs.package-name }}
sha256: ${{ needs.provenance.outputs.package-download-sha256 }}
- name: Publish main
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
pnpm publish --no-git-checks "$TARBALL" --tag "$TAG"
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TARBALL: ${{ needs.provenance.outputs.package-name }}
TAG: ${{ steps.tag.outputs.tag }}
NPM_CONFIG_PROVENANCE: true
NPM_CONFIG_ACCESS: public
- name: Create Github Release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
with:
script: await require('./scripts/github-release.js')({ github, context })
- name: Publish Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()
merge-release-to-main:
needs: state
name: Create PR back to main branch
permissions:
contents: write
pull-requests: write
if: needs.state.outputs.merge == 'true'
runs-on: ubuntu-latest
env:
MERGE_BRANCH: merge/${{ github.ref_name }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Create branch to merge
run: |
git checkout -b "$MERGE_BRANCH" "$GITHUB_REF_NAME"
git push -f origin "$MERGE_BRANCH"
- name: Create PR back to main
run: |
gh pr create \
--title "chore: 🤖 [Automated PR] Merge $MERGE_BRANCH into the main branch" \
--body "This PR merges the $MERGE_BRANCH branch to the main branch." \
--base main \
--head $MERGE_BRANCH
env:
GITHUB_TOKEN: ${{ steps.gh-app-token.outputs.token }}
- name: Merge Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()
sbom:
needs: [provenance, publish]
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/create-github-app-token@af35edadc00be37caa72ed9f3e6d5f7801bfdf09 # v1.11.7
id: gh-app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.5.4
with:
token: ${{ steps.gh-app-token.outputs.token }}
- name: Create temp dir
id: temp-dir
run: |
set -euo pipefail
temp_dir=$(mktemp -d)
echo "path=${temp_dir}" >>"${GITHUB_OUTPUT}"
- name: Get package version
run: echo "PACKAGE_VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Generate SBOM
uses: anchore/sbom-action@d94f46e13c6c62f59525ac9a1e147a99dc0b9bf5
with:
artifact-name: sbom-${{ github.event.repository.name }}-${{ env.PACKAGE_VERSION }}.spdx.json
output-file: /${{ steps.temp-dir.outputs.path }}/sbom-${{ github.event.repository.name }}-${{ env.PACKAGE_VERSION }}.spdx.json
upload-artifact: true
upload-release-assets: true
upload-artifact-retention: 1
- name: Download Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
- name: Upload SBOM to GitHub Release
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3
with:
files: |
${{ steps.temp-dir.outputs.path }}/sbom-${{ github.event.repository.name }}-${{ env.PACKAGE_VERSION }}.spdx.json
${{ needs.provenance.outputs.provenance-download-name }}
tag_name: v${{ env.PACKAGE_VERSION }}
env:
GITHUB_TOKEN: ${{ steps.gh-app-token.outputs.token }}
- name: Upload attestations SLSA
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be
with:
subject-path: ${{ needs.provenance.outputs.provenance-download-name }}
subject-name: ${{ github.event.repository.name }}-${{ env.PACKAGE_VERSION }}
- name: Upload attestations SBOM
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be
with:
subject-path: /${{ steps.temp-dir.outputs.path }}/sbom-${{ github.event.repository.name }}-${{ env.PACKAGE_VERSION }}.spdx.json
- name: SBOM Job Slack Notification
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '${{ vars.SLACK_CHANNEL }}'
if: always()