22# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33
44name : CI
5- permissions :
6- contents : write
7- pull-requests : write
5+
86on :
97 push :
108 branches :
1614
1715jobs :
1816 build :
19-
2017 runs-on : ubuntu-latest
21-
2218 strategy :
2319 matrix :
24- node-version :
25- - 20.x
26- - 22.x
20+ node-version : [20, 22]
2721
2822 steps :
2923 - uses : actions/checkout@v6
3630 - run : npm test
3731 - run : npm run build --if-present
3832 - name : Save build
39- if : matrix.node-version == '20.x'
33+ if : matrix.node-version == 20
4034 uses : actions/upload-artifact@v6
4135 with :
4236 name : build
@@ -60,39 +54,47 @@ jobs:
6054 npm-publish-build :
6155 needs : build
6256 runs-on : ubuntu-latest
57+ permissions :
58+ id-token : write
59+ contents : read
6360 steps :
6461 - uses : actions/download-artifact@v7
6562 with :
6663 name : build
6764 - uses : actions/setup-node@v6
6865 with :
69- node-version : 20.x
66+ node-version : 20
67+ registry-url : ' https://registry.npmjs.org'
68+ - name : Update npm to latest (required for OIDC)
69+ run : npm install -g npm@latest
7070 - uses : rlespinasse/github-slug-action@v3.x
7171 - name : Append commit hash to package version
7272 run : ' sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
7373 - name : Disable pre- and post-publish actions
7474 run : ' sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
75- - uses : JS-DevTools/ npm-publish@v4.1.4
75+ - name : Publish to npm
7676 if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
77- with :
78- token : ${{ secrets.NPM_TOKEN }}
79- tag : ${{ env.GITHUB_REF_SLUG }}
77+ run : npm publish --tag ${{ env.GITHUB_REF_SLUG }}
8078
8179 npm-publish-latest :
8280 needs : [build, npm-publish-build]
8381 runs-on : ubuntu-latest
8482 if : github.ref == 'refs/heads/main'
83+ permissions :
84+ id-token : write # Required for OIDC
85+ contents : read
8586 steps :
8687 - uses : actions/download-artifact@v7
8788 with :
8889 name : build
8990 - uses : actions/setup-node@v6
9091 with :
91- node-version : 20.x
92+ node-version : 20
93+ registry-url : ' https://registry.npmjs.org'
94+ - name : Update npm to latest (required for OIDC)
95+ run : npm install -g npm@latest
9296 - name : Disable pre- and post-publish actions
9397 run : ' sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
94- - uses : JS-DevTools/ npm-publish@v4.1.4
98+ - name : Publish to npm
9599 if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
96- with :
97- token : ${{ secrets.NPM_TOKEN }}
98- tag : latest
100+ run : npm publish --tag latest
0 commit comments