@@ -11,21 +11,56 @@ jobs:
1111 publish :
1212 runs-on : ubuntu-latest
1313 permissions :
14- id-token : write # Required for OIDC
15- contents : read
14+ id-token : write # Required for OIDC (npm provenance + GitHub attestation)
15+ contents : write # Required to create GitHub releases and upload assets
16+ attestations : write # Required for actions/attest-build-provenance
17+
1618 steps :
17- # checkout@v6
18- - uses : jonobr1/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
19- # setup-node@v6
20- - uses : jonobr1/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f
19+ - uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+ - uses : actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
2121 with :
2222 node-version : ' 24.14.1'
2323 registry-url : ' https://registry.npmjs.org'
2424
2525 # Ensure npm 11.5.1 or later is installed
2626 - name : Update npm
27- run : npm install -g npm@latest
27+ run : npm install -g npm@11.5.1
2828 - run : npm ci
29- - run : npm run build --if-present
30- # - run: npm test
31- - run : npm publish
29+ - run : npm run build
30+
31+ - name : Generate SLSA provenance attestation
32+ id : attest
33+ uses : actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
34+ with :
35+ subject-path : |
36+ build/two.js
37+ build/two.module.js
38+ build/two.min.js
39+
40+ - name : Stage provenance bundle for release
41+ env :
42+ BUNDLE_PATH : ${{ steps.attest.outputs.bundle-path }}
43+ TAG : ${{ github.ref_name }}
44+ run : cp "$BUNDLE_PATH" "two.js-${TAG}.intoto.jsonl"
45+
46+ - name : Upload provenance bundle as artifact
47+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
48+ with :
49+ name : provenance-bundle-${{ github.ref_name }}
50+ path : two.js-${{ github.ref_name }}.intoto.jsonl
51+
52+ - name : Publish to npm with provenance
53+ run : npm publish --provenance
54+
55+ - name : Create GitHub Release
56+ env :
57+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
58+ TAG : ${{ github.ref_name }}
59+ run : |
60+ gh release create "$TAG" \
61+ --title "Official Stable Release of $TAG" \
62+ --generate-notes \
63+ build/two.js \
64+ build/two.module.js \
65+ build/two.min.js \
66+ "two.js-${TAG}.intoto.jsonl"
0 commit comments