1- # This workflow will run tests using node and then publish a package to npm when a release is created
2- # For more information see: https://help.github .com/actions/language-and-framework-guides/publishing-nodejs-packages
1+ # This workflow will build and publish a package to npm when a release is created
2+ # For more information see: https://docs.npmjs .com/trusted-publishers
33
44name : npm publish
55
66on :
77 release :
88 types : [published]
99
10+ permissions :
11+ id-token : write
12+ contents : read
13+
1014env :
1115 TAG : ' ${{ github.event.release.tag_name }}'
1216
1519 runs-on : ubuntu-latest
1620 steps :
1721 - name : Checkout code
18- uses : actions/checkout@v4
22+ uses : actions/checkout@v5
1923 - name : Validate version tag pattern
2024 run : |
2125 if [[ ! "${{ env.TAG }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
@@ -41,31 +45,29 @@ jobs:
4145 runs-on : ubuntu-latest
4246 needs : validate-release
4347 steps :
44- - uses : actions/checkout@v4
45- - uses : actions/setup-node@v4
48+ - uses : actions/checkout@v5
49+ - uses : actions/setup-node@v6
4650 with :
4751 node-version : 22
52+ registry-url : https://registry.npmjs.org/
53+ cache : ' npm'
4854 - run : npm ci
4955 - run : npm run eslint
50- - run : npm test
56+ - run : npm run test
5157
5258 build-and-publish :
5359 runs-on : ubuntu-latest
5460 needs : test
55- permissions :
56- contents : read
57- id-token : write
5861 steps :
59- - uses : actions/checkout@v4
60- - uses : actions/setup-node@v4
62+ - uses : actions/checkout@v5
63+ - uses : actions/setup-node@v6
6164 with :
6265 node-version : 22
6366 registry-url : https://registry.npmjs.org/
6467 cache : ' npm'
65- - run : npm install -g npm
68+ - name : Update npm
69+ run : npm install -g npm@latest
6670 - run : npm ci
6771 - run : npm run build
6872 - name : Publish package
69- run : npm publish --provenance --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
70- env :
71- NODE_AUTH_TOKEN : ${{ secrets.NPM_SECRET }}
73+ run : npm publish --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
0 commit comments