Skip to content

Commit bb718ed

Browse files
committed
fix(ci): publish to npm via OIDC trusted publishing
1 parent 6d27e3c commit bb718ed

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88

99
concurrency: ${{ github.workflow }}-${{ github.ref }}
1010

11+
permissions:
12+
contents: write
13+
id-token: write
14+
1115
jobs:
1216
publish:
1317
if: >
@@ -21,22 +25,12 @@ jobs:
2125
version: 8
2226
- uses: actions/setup-node@v4
2327
with:
24-
node-version: 20.x
28+
node-version: 22.x
2529
registry-url: https://registry.npmjs.org
2630
cache: pnpm
2731

28-
- name: Verify npm publish credentials
29-
env:
30-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31-
run: |
32-
if [ -z "$NODE_AUTH_TOKEN" ]; then
33-
echo "::error::NPM_TOKEN secret is not set. Add an npm Automation token with publish access to ts-hover-prettify under GitHub repo Settings → Secrets → Actions."
34-
exit 1
35-
fi
36-
npm whoami || {
37-
echo "::error::npm auth failed. Regenerate an npm Automation token for account 'marco.antolini' and update the NPM_TOKEN secret."
38-
exit 1
39-
}
32+
- name: Ensure npm supports trusted publishing (OIDC)
33+
run: npm install -g npm@latest && npm --version && node --version
4034

4135
- run: pnpm install --frozen-lockfile
4236
- name: Create Release Pull Request or Publish
@@ -46,5 +40,3 @@ jobs:
4640
publish: pnpm run release
4741
env:
4842
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
50-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)