33
44name : CI
55
6- permissions :
7- contents : write
8- pull-requests : write
96on :
107 push :
118 branches :
2219
2320 strategy :
2421 matrix :
25- node-version :
26- - 20.x
27- - 22.x
22+ node-version : [20, 22]
2823
2924 steps :
3025 - uses : actions/checkout@v6
3732 - run : npm test
3833 - run : npm run build --if-present
3934 - name : Save build
40- if : matrix.node-version == '20.x'
35+ if : matrix.node-version == 20
4136 uses : actions/upload-artifact@v6
4237 with :
4338 name : build
@@ -61,39 +56,47 @@ jobs:
6156 npm-publish-build :
6257 needs : build
6358 runs-on : ubuntu-latest
59+ permissions :
60+ id-token : write
61+ contents : read
6462 steps :
6563 - uses : actions/download-artifact@v7
6664 with :
6765 name : build
6866 - uses : actions/setup-node@v6
6967 with :
70- node-version : 20.x
68+ node-version : 20
69+ registry-url : ' https://registry.npmjs.org'
70+ - name : Update npm to latest (required for OIDC)
71+ run : npm install -g npm@latest
7172 - uses : rlespinasse/github-slug-action@v3.x
7273 - name : Append commit hash to package version
7374 run : ' sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
7475 - name : Disable pre- and post-publish actions
7576 run : ' sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
76- - uses : JS-DevTools/ npm-publish@v4.1.4
77+ - name : Publish to npm
7778 if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
78- with :
79- token : ${{ secrets.NPM_TOKEN }}
80- tag : ${{ env.GITHUB_REF_SLUG }}
79+ run : npm publish --tag ${{ env.GITHUB_REF_SLUG }}
8180
8281 npm-publish-latest :
8382 needs : [build, npm-publish-build]
8483 runs-on : ubuntu-latest
8584 if : github.ref == 'refs/heads/main'
85+ permissions :
86+ id-token : write # Required for OIDC
87+ contents : read
8688 steps :
8789 - uses : actions/download-artifact@v7
8890 with :
8991 name : build
9092 - uses : actions/setup-node@v6
9193 with :
92- node-version : 20.x
94+ node-version : 20
95+ registry-url : ' https://registry.npmjs.org'
96+ - name : Update npm to latest (required for OIDC)
97+ run : npm install -g npm@latest
9398 - name : Disable pre- and post-publish actions
9499 run : ' sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
95- - uses : JS-DevTools/ npm-publish@v4.1.4
100+ - name : Publish to npm
96101 if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
97- with :
98- token : ${{ secrets.NPM_TOKEN }}
99- tag : latest
102+ run : npm publish --tag latest
0 commit comments