Skip to content

Commit c7db6de

Browse files
Snailedltclaude
andcommitted
ci: publish to npm with trusted publishing (OIDC)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ff435a0 commit c7db6de

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎.github/workflows/npm_publish.yml‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@ name: "Publish to npm"
22
on:
33
release:
44
types: [released]
5+
# Allows re-running a failed publish by hand from the Actions tab
6+
workflow_dispatch:
7+
permissions: {}
58
jobs:
69
publish:
710
environment: release
811
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # Required for npm trusted publishing (OIDC)
14+
contents: read
915
steps:
10-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1117
with:
1218
# "ref" specifies the branch to check out.
1319
# "github.event.release.target_commitish" is a global variable and specifies the branch the release targeted
20+
# It's empty on manual runs, so the branch selected in the Actions tab is used instead
1421
ref: ${{ github.event.release.target_commitish }}
15-
- name: Use Node.js v16
16-
uses: actions/setup-node@v4
22+
persist-credentials: false
23+
# Node 24 ships with npm 11.5.1 or later, which trusted publishing requires
24+
- name: Use Node.js v24
25+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
1726
with:
1827
node-version: 24
19-
registry-url: https://registry.npmjs.org/ # Specifies the registry, this field is required!
20-
- run: npm ci
28+
package-manager-cache: false
29+
# No dependencies are installed: the package has no build step, and skipping
30+
# them keeps third-party install scripts out of the job that can publish.
31+
# Authenticates through the trusted publisher configured on npmjs.com, so no token is needed
2132
- run: npm publish
22-
env:
23-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }}

0 commit comments

Comments
 (0)