-
Notifications
You must be signed in to change notification settings - Fork 172
800 lines (721 loc) · 28.9 KB
/
release-stable.yml
File metadata and controls
800 lines (721 loc) · 28.9 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
name: Stable Release Pipeline
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
# Minimal permissions for security
permissions:
contents: read
jobs:
spell-check:
name: Spell Check
uses: ./.github/workflows/spell-check.yml
permissions:
contents: read
with:
soft-fail: false
markdown-lint:
name: Markdown Lint
uses: ./.github/workflows/markdown-lint.yml
permissions:
contents: read
with:
soft-fail: false
table-format:
name: Table Format Check
uses: ./.github/workflows/table-format.yml
permissions:
contents: read
with:
soft-fail: false
dependency-pinning-scan:
name: Dependency Pinning Scan
uses: ./.github/workflows/dependency-pinning-scan.yml
permissions:
contents: read
security-events: write # Required for SARIF upload to Security tab
with:
soft-fail: false
upload-sarif: true
upload-artifact: true
action-version-consistency-scan:
name: Action Version Consistency Scan
uses: ./.github/workflows/action-version-consistency-scan.yml
permissions:
contents: read
security-events: write # Required for SARIF upload to Security tab
with:
soft-fail: false
upload-sarif: true
upload-artifact: true
gitleaks-scan:
name: Gitleaks Secret Scan
uses: ./.github/workflows/gitleaks-scan.yml
permissions:
contents: read
security-events: write # Required for SARIF upload to Security tab
with:
soft-fail: false
upload-sarif: true
upload-artifact: true
pester-tests:
name: PowerShell Tests
uses: ./.github/workflows/pester-tests.yml
permissions:
contents: read
id-token: write
with:
soft-fail: false
changed-files-only: false
code-coverage: true
docusaurus-tests:
name: Docusaurus Tests
uses: ./.github/workflows/docusaurus-tests.yml
permissions:
contents: read
with:
soft-fail: false
discover-python-projects:
name: Discover Python Projects
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
directories: ${{ steps.find.outputs.directories }}
has-projects: ${{ steps.find.outputs.has-projects }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Find Python projects
id: find
shell: pwsh
run: |
$projectList = @(Get-ChildItem -Recurse -Force -Filter pyproject.toml |
Where-Object { $_.FullName -notmatch 'node_modules' } |
ForEach-Object { Resolve-Path -Relative $_.DirectoryName } |
ForEach-Object { $_ -replace '^\.[\\/]', '' } |
Sort-Object)
$jsonItems = $projectList | ForEach-Object { $_ | ConvertTo-Json -Compress }
$dirs = '[' + (($jsonItems) -join ',') + ']'
"directories=$dirs" >> $env:GITHUB_OUTPUT
if ($projectList.Count -eq 0) {
"has-projects=false" >> $env:GITHUB_OUTPUT
Write-Output 'No Python projects found'
} else {
"has-projects=true" >> $env:GITHUB_OUTPUT
Write-Output "Found Python projects: $dirs"
}
python-lint:
name: "Python Lint (${{ matrix.directory }})"
needs: discover-python-projects
if: needs.discover-python-projects.outputs.has-projects == 'true'
strategy:
fail-fast: false
matrix:
directory: ${{ fromJson(needs.discover-python-projects.outputs.directories) }}
uses: ./.github/workflows/python-lint.yml
permissions:
contents: read
with:
soft-fail: false
changed-files-only: false
working-directory: ${{ matrix.directory }}
pytest:
name: "Python Tests (${{ matrix.directory }})"
needs: discover-python-projects
if: needs.discover-python-projects.outputs.has-projects == 'true'
uses: ./.github/workflows/pytest-tests.yml
permissions:
contents: read
id-token: write
with:
working-directory: ${{ matrix.directory }}
soft-fail: false
changed-files-only: false
strategy:
fail-fast: false
matrix:
directory: ${{ fromJson(needs.discover-python-projects.outputs.directories) }}
release-please:
name: Release Please
needs:
- spell-check
- markdown-lint
- table-format
- dependency-pinning-scan
- gitleaks-scan
- pester-tests
- docusaurus-tests
- python-lint
- pytest
# Allow release-please to run when conditional CI jobs (python-lint,
# pytest) are skipped. Block only on actual failures or cancellations.
if: ${{ !cancelled() && !failure() }}
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
major: ${{ steps.release.outputs.major }}
minor: ${{ steps.release.outputs.minor }}
patch: ${{ steps.release.outputs.patch }}
permissions:
contents: write
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v2.0.0
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Run release-please
id: release
uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
with:
token: ${{ steps.app-token.outputs.token }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# On release commits, skip PR creation to prevent bogus PRs
# from draft release lazy tag timing. Release commits have zero
# unreleased changes so skipping loses nothing. The tag is
# created in the next step, ensuring subsequent runs find it.
skip-github-pull-request: ${{ github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(main)') }}
- name: Validate even-minor convention
if: ${{ steps.release.outputs.release_created == 'true' }}
run: |
MINOR="${{ steps.release.outputs.minor }}"
if (( MINOR % 2 != 0 )); then
echo "::error::Release version ${{ steps.release.outputs.version }} has odd minor ($MINOR). Even/odd convention requires even minor for stable releases."
exit 1
fi
# Workaround: release-please with "draft": true uses lazy tag
# creation. The git tag is not materialized until the release is
# published. Without the tag, release-please cannot find the draft
# on subsequent runs, breaking version anchoring and causing bogus
# major-version PRs. The skip-github-pull-request conditional above
# prevents PR creation on release commits (zero unreleased changes),
# and this step creates the tag so subsequent runs find the release.
# Replace both workarounds with "force-tag-creation": true in
# release-please-config.json once release-please-action ships a
# version that includes googleapis/release-please#2627.
- name: Create git tag for draft release
if: ${{ steps.release.outputs.release_created == 'true' }}
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
TAG="${{ steps.release.outputs.tag_name }}"
REPO="${{ github.repository }}"
if ! gh api "/repos/$REPO/git/refs/tags/$TAG" --silent 2>/dev/null; then
gh api "/repos/$REPO/git/refs" \
-f "ref=refs/tags/$TAG" \
-f "sha=${{ github.sha }}"
echo "Created git tag $TAG -> ${{ github.sha }}"
else
echo "Git tag $TAG already exists"
fi
close-milestone:
name: Close Release Milestone
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Close milestone for released version
env:
GH_TOKEN: ${{ github.token }}
MAJOR: ${{ needs.release-please.outputs.major }}
MINOR: ${{ needs.release-please.outputs.minor }}
run: |
REPO="${{ github.repository }}"
TITLE="v${MAJOR}.${MINOR}.0"
NUMBER=$(gh api "/repos/$REPO/milestones?state=open&per_page=100" \
--jq ".[] | select(.title == \"$TITLE\") | .number")
if [ -n "$NUMBER" ]; then
gh api "/repos/$REPO/milestones/$NUMBER" \
-X PATCH -f state=closed
echo "✅ Closed milestone $TITLE (#$NUMBER)"
else
echo "ℹ️ No open milestone found matching '$TITLE' — skipping"
fi
reset-prerelease:
name: Reset Pre-Release Branch
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v2.0.0
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Install PowerShell-Yaml
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name PowerShell-Yaml | Where-Object { $_.Version -eq '0.4.7' })) {
Install-Module -Name PowerShell-Yaml -RequiredVersion 0.4.7 -Force -Scope CurrentUser
}
- name: Reset pre-release branch
id: reset-branch
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
REPO: ${{ github.repository }}
run: |
BRANCH="prerelease/next"
RELEASED="${{ needs.release-please.outputs.version }}"
MAJOR=$(echo "$RELEASED" | cut -d. -f1)
MINOR=$(echo "$RELEASED" | cut -d. -f2)
PRE_VERSION="${MAJOR}.$((MINOR + 1)).0"
echo "pre-version=${PRE_VERSION}" >> "$GITHUB_OUTPUT"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git"
# Build the version-bump commit before pushing.
# A single force-push of the final state prevents the remote from
# ever seeing prerelease/next identical to main, which would cause
# GitHub to auto-close the open PR.
git checkout -B "$BRANCH"
# Update all version-tracked files and regenerate plugin outputs
pwsh -File scripts/release/Update-VersionFiles.ps1 -Version "$PRE_VERSION"
git add -A
git commit -m "chore: reset pre-release version to ${PRE_VERSION}" || echo "No version changes to commit"
git push --force origin "$BRANCH"
- name: Create or update pre-release PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
REPO: ${{ github.repository }}
run: |
BRANCH="prerelease/next"
RELEASED="${{ needs.release-please.outputs.version }}"
PRE_VERSION="${{ steps.reset-branch.outputs.pre-version }}"
TITLE="chore(main): pre-release ${PRE_VERSION}"
BODY="## Pre-Release ${PRE_VERSION}
Reset after release ${RELEASED}. Next push to main will update this PR.
---
*Managed automatically by pre-release workflow.*"
PR_NUMBER=$(gh pr list --head "$BRANCH" --state open \
--json number --jq '.[0].number // empty' \
-R "$REPO")
if [ -n "$PR_NUMBER" ]; then
gh pr edit "$PR_NUMBER" \
--title "$TITLE" \
--body "$BODY" \
-R "$REPO"
echo "Updated PR #$PR_NUMBER to $PRE_VERSION"
else
gh pr create \
--head "$BRANCH" \
--base main \
--title "$TITLE" \
--body "$BODY" \
--label "autorelease: prerelease" \
-R "$REPO"
echo "Created new pre-release PR"
fi
extension-package-release:
name: Package VS Code Extensions (Release)
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
uses: ./.github/workflows/extension-package.yml
with:
version: ${{ needs.release-please.outputs.version }}
permissions:
contents: read
plugin-package-release:
name: Package Plugins (Release)
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
uses: ./.github/workflows/plugin-package.yml
with:
version: ${{ needs.release-please.outputs.version }}
permissions:
contents: read
generate-dependency-sbom:
name: Generate Dependency SBOM
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
# write required for gh release upload to attach SBOM to the release
contents: write
steps:
- name: Checkout dependency manifests
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: |
package.json
package-lock.json
.syft.yaml
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Generate dependency SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
with:
path: .
format: spdx-json
output-file: dependencies.spdx.json
upload-release-assets: false
upload-artifact: false
config: .syft.yaml
dependency-snapshot: true
- name: Upload dependency SBOM artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sbom-dependencies
path: dependencies.spdx.json
- name: Upload dependency SBOM to release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${{ needs.release-please.outputs.tag_name }}" \
"dependencies.spdx.json" \
--clobber -R "${{ github.repository }}"
attest-and-upload:
name: Attest and Upload (${{ matrix.id }})
needs: [release-please, extension-package-release, generate-dependency-sbom]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.extension-package-release.outputs.collections-matrix) }}
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write
steps:
- name: Checkout Syft config
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .syft.yaml
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Download dependency SBOM
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sbom-dependencies
path: ./sbom
- name: Download VSIX artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: extension-vsix-${{ matrix.id }}
path: ./dist
- name: Resolve VSIX filename
id: vsix
run: |
shopt -s nullglob
files=(dist/*.vsix)
if [[ ${#files[@]} -eq 0 ]]; then
echo "::error::No VSIX file found in dist/"
exit 1
fi
if [[ ${#files[@]} -gt 1 ]]; then
echo "::error::Expected exactly one VSIX file but found ${#files[@]}: ${files[*]}"
exit 1
fi
VSIX_FILE="${files[0]}"
VSIX_NAME=$(basename "$VSIX_FILE")
echo "file=$VSIX_FILE" >> "$GITHUB_OUTPUT"
echo "name=$VSIX_NAME" >> "$GITHUB_OUTPUT"
- name: Generate SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
with:
file: ${{ steps.vsix.outputs.file }}
format: spdx-json
output-file: dist/${{ steps.vsix.outputs.name }}.spdx.json
artifact-name: sbom-${{ matrix.id }}
upload-release-assets: false
upload-artifact: true
config: .syft.yaml
- name: Verify SBOM files exist
run: |
test -f "dist/${{ steps.vsix.outputs.name }}.spdx.json" \
|| { echo "::error::Per-VSIX SBOM not found: dist/${{ steps.vsix.outputs.name }}.spdx.json"; exit 1; }
test -f "sbom/dependencies.spdx.json" \
|| { echo "::error::Dependency SBOM not found: sbom/dependencies.spdx.json"; exit 1; }
- name: Attest build provenance
id: attest
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: ${{ steps.vsix.outputs.file }}
- name: Attest SBOM
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: ${{ steps.vsix.outputs.file }}
sbom-path: dist/${{ steps.vsix.outputs.name }}.spdx.json
- name: Attest dependency SBOM
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: ${{ steps.vsix.outputs.file }}
sbom-path: sbom/dependencies.spdx.json
- name: Upload assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
BUNDLE_PATH: ${{ steps.attest.outputs.bundle-path }}
run: |
cp "$BUNDLE_PATH" \
"dist/${{ steps.vsix.outputs.name }}.sigstore.json"
jq -c '.dsseEnvelope' "$BUNDLE_PATH" > \
"dist/${{ steps.vsix.outputs.name }}.intoto.jsonl"
gh release upload "${{ needs.release-please.outputs.tag_name }}" \
"${{ steps.vsix.outputs.file }}" \
"dist/${{ steps.vsix.outputs.name }}.spdx.json" \
"dist/${{ steps.vsix.outputs.name }}.sigstore.json" \
"dist/${{ steps.vsix.outputs.name }}.intoto.jsonl" \
--clobber -R "${{ github.repository }}"
upload-plugin-packages:
name: Attest and Upload Plugin (${{ matrix.id }})
needs: [release-please, plugin-package-release, generate-dependency-sbom]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.plugin-package-release.outputs.collections-matrix) }}
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write
steps:
- name: Checkout Syft config
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .syft.yaml
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Download dependency SBOM
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sbom-dependencies
path: ./sbom
- name: Download plugin artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: plugin-package-${{ matrix.id }}
path: ./dist/plugins
- name: Verify plugin archive exists
run: |
PLUGIN_ARCHIVE="dist/plugins/${{ matrix.id }}.zip"
if [ ! -f "$PLUGIN_ARCHIVE" ]; then
echo "::error::Plugin archive not found for collection ${{ matrix.id }}"
exit 1
fi
- name: Generate SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
with:
file: dist/plugins/${{ matrix.id }}.zip
format: spdx-json
output-file: dist/plugins/${{ matrix.id }}.zip.spdx.json
artifact-name: sbom-plugin-${{ matrix.id }}
upload-release-assets: false
upload-artifact: true
config: .syft.yaml
- name: Verify SBOM files exist
run: |
test -f "dist/plugins/${{ matrix.id }}.zip.spdx.json" \
|| { echo "::error::Per-plugin SBOM not found: dist/plugins/${{ matrix.id }}.zip.spdx.json"; exit 1; }
test -f "sbom/dependencies.spdx.json" \
|| { echo "::error::Dependency SBOM not found: sbom/dependencies.spdx.json"; exit 1; }
- name: Attest build provenance
id: attest
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-path: dist/plugins/${{ matrix.id }}.zip
- name: Attest SBOM
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: dist/plugins/${{ matrix.id }}.zip
sbom-path: dist/plugins/${{ matrix.id }}.zip.spdx.json
- name: Attest dependency SBOM
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-path: dist/plugins/${{ matrix.id }}.zip
sbom-path: sbom/dependencies.spdx.json
- name: Upload assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
BUNDLE_PATH: ${{ steps.attest.outputs.bundle-path }}
run: |
cp "$BUNDLE_PATH" \
"dist/plugins/${{ matrix.id }}.zip.sigstore.json"
jq -c '.dsseEnvelope' "$BUNDLE_PATH" > \
"dist/plugins/${{ matrix.id }}.zip.intoto.jsonl"
gh release upload "${{ needs.release-please.outputs.tag_name }}" \
"dist/plugins/${{ matrix.id }}.zip" \
"dist/plugins/${{ matrix.id }}.zip.spdx.json" \
"dist/plugins/${{ matrix.id }}.zip.sigstore.json" \
"dist/plugins/${{ matrix.id }}.zip.intoto.jsonl" \
--clobber -R "${{ github.repository }}"
sbom-diff:
name: SBOM Dependency Diff
needs: [release-please, generate-dependency-sbom]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
steps:
- name: Download current dependency SBOM
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: sbom-dependencies
path: ./current
- name: Verify current dependency SBOM
run: |
test -f "current/dependencies.spdx.json" \
|| { echo "::error::Current dependency SBOM not found in artifact"; exit 1; }
- name: Download previous release dependency SBOM
id: previous
env:
GH_TOKEN: ${{ github.token }}
run: |
REPO="${{ github.repository }}"
PREV_TAG=$(gh api "/repos/$REPO/releases/latest" --jq '.tag_name' 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "No previous release found"
echo "found=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Previous release: $PREV_TAG"
echo "tag=$PREV_TAG" >> "$GITHUB_OUTPUT"
mkdir -p previous
if gh release download "$PREV_TAG" -R "$REPO" -p "dependencies.spdx.json" -D previous 2>/dev/null; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "Previous release has no dependency SBOM"
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Generate dependency diff
if: ${{ steps.previous.outputs.found == 'true' }}
run: |
python3 <<'PYTHON'
import json
import pathlib
def load_packages(path):
with open(path) as f:
data = json.load(f)
root_ids = set(data.get('documentDescribes', []))
pkgs = {}
for p in data.get('packages', []):
if p.get('SPDXID', '') in root_ids:
continue
name = p.get('name', 'unknown')
version = p.get('versionInfo', 'unknown')
pkgs[name] = version
return pkgs
current = load_packages('current/dependencies.spdx.json')
previous = load_packages('previous/dependencies.spdx.json')
added = {k: v for k, v in current.items() if k not in previous}
removed = {k: v for k, v in previous.items() if k not in current}
changed = {
k: (previous[k], current[k])
for k in current
if k in previous and current[k] != previous[k]
}
lines = ['# Dependency SBOM Diff', '']
if not added and not removed and not changed:
lines.append('No dependency changes detected.')
else:
if added:
lines.extend(['## Added', '', '| Package | Version |', '|---------|---------|'])
for name in sorted(added):
lines.append(f'| {name} | {added[name]} |')
lines.append('')
if removed:
lines.extend(['## Removed', '', '| Package | Version |', '|---------|---------|'])
for name in sorted(removed):
lines.append(f'| {name} | {removed[name]} |')
lines.append('')
if changed:
lines.extend([
'## Version Changes', '',
'| Package | Previous | Current |',
'|---------|----------|---------|',
])
for name in sorted(changed):
old, new = changed[name]
lines.append(f'| {name} | {old} | {new} |')
lines.append('')
lines.extend(['', '_Generated from SPDX JSON dependency SBOMs._', ''])
pathlib.Path('dependency-diff.md').write_text('\n'.join(lines))
count = len(added) + len(removed) + len(changed)
print(f'Diff: {len(added)} added, {len(removed)} removed, {len(changed)} changed')
PYTHON
- name: Upload diff to GitHub Release
if: ${{ steps.previous.outputs.found == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${{ needs.release-please.outputs.tag_name }}" \
"dependency-diff.md" \
--clobber -R "${{ github.repository }}"
append-verification-notes:
name: Append Verification Instructions
needs: [release-please, attest-and-upload, upload-plugin-packages]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Append verification section to release notes
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.release-please.outputs.tag_name }}"
REPO="${{ github.repository }}"
gh release view "$TAG" --json body --jq '.body' -R "$REPO" > notes.md
cat >> notes.md <<'EOF'
## Verifying Downloads
All release assets include [Sigstore](https://www.sigstore.dev/) build-provenance
attestations generated by GitHub Actions. Verify any downloaded asset with the
GitHub CLI:
```bash
# Verify a VSIX extension package
gh attestation verify <file>.vsix --repo microsoft/hve-core
# Verify a plugin ZIP package
gh attestation verify <file>.zip --repo microsoft/hve-core
```
See [SECURITY.md](https://github.com/microsoft/hve-core/blob/main/SECURITY.md)
for full supply-chain verification details including SBOM validation.
EOF
gh release edit "$TAG" --notes-file notes.md -R "$REPO"
publish-release:
name: Publish GitHub Release
needs: [release-please, attest-and-upload, upload-plugin-packages, sbom-diff, append-verification-notes]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ needs.release-please.outputs.tag_name }}"
REPO="${{ github.repository }}"
# Promote draft to published. The release becomes immutable
# after publish with all assets already attached.
gh release edit "$TAG" --draft=false -R "$REPO"