Skip to content

Commit af11e57

Browse files
authored
fix: migrate release workflow to OIDC trusted publishing (#38)
- Replace secret-based npm auth (.npmrc + NPMJS_TOKEN) with OIDC trusted publishing via setup-node registry-url - Add skipChecks: true to release-it config to skip npm whoami/ping which fail with OIDC tokens - Add --provenance --access public to npm publish args - Upgrade npm to latest in setup action since Node 20 bundles npm v10.8 but OIDC requires npm >= 11.5.1 - Upgrade actions to v4 (setup-node, cache, checkout) - Remove unnecessary packages:write permission
1 parent cc0a738 commit af11e57

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.github/actions/setup/action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.js
8-
uses: actions/setup-node@v3
8+
uses: actions/setup-node@v4
99
with:
1010
node-version-file: .nvmrc
11+
registry-url: 'https://registry.npmjs.org'
12+
13+
- name: Upgrade npm for OIDC support
14+
run: npm install -g npm@latest
15+
shell: bash
1116

1217
- name: Cache dependencies
1318
id: yarn-cache
14-
uses: actions/cache@v3
19+
uses: actions/cache@v4
1520
with:
1621
path: |
1722
**/node_modules

.github/workflows/release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ jobs:
99
permissions:
1010
contents: write
1111
id-token: write
12-
packages: write
1312
steps:
1413
- name: Checkout
15-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1615
with:
1716
fetch-depth: 0
1817

@@ -28,9 +27,6 @@ jobs:
2827
- name: Build package
2928
run: yarn prepare
3029

31-
- name: Setup .npmrc (NPM)
32-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" >> ~/.npmrc
33-
3430
- name: Setup Git
3531
run: |
3632
git config --global user.name "github-actions[bot]"
@@ -41,4 +37,3 @@ jobs:
4137
run: yarn release
4238
env:
4339
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
NPM_TOKEN: ${{ secrets.NPMJS_TOKEN }}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@
143143
"requireCleanWorkingDir": false
144144
},
145145
"npm": {
146-
"publish": true
146+
"publish": true,
147+
"skipChecks": true,
148+
"publishArgs": [
149+
"--provenance --access public"
150+
]
147151
},
148152
"github": {
149153
"release": true

0 commit comments

Comments
 (0)