Skip to content

Commit 24e00ea

Browse files
rgarciacursoragent
andcommitted
chore: switch npm publish from token auth to OIDC trusted publishers
Replace NPM_TOKEN-based authentication with npm's OIDC trusted publishers. This eliminates the need for a long-lived npm token secret and adds provenance attestation to published packages. Changes: - publish-npm.yml: add id-token:write permission, setup-node with registry-url, remove NPM_TOKEN env - bin/publish-npm: remove npm config set for auth token, switch from yarn publish to npm publish --provenance --access public - bin/check-release-environment: remove NPM_TOKEN check (no longer needed) - release-doctor.yml: remove NPM_TOKEN env Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1061df9 commit 24e00ea

File tree

4 files changed

+10
-27
lines changed

4 files changed

+10
-27
lines changed

.github/workflows/publish-npm.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
release:
99
types: [published]
1010

11+
permissions:
12+
id-token: write # Required for npm OIDC trusted publishers
13+
contents: read
14+
1115
jobs:
1216
publish:
1317
name: publish
@@ -17,9 +21,10 @@ jobs:
1721
- uses: actions/checkout@v6
1822

1923
- name: Set up Node
20-
uses: actions/setup-node@v3
24+
uses: actions/setup-node@v4
2125
with:
2226
node-version: '20'
27+
registry-url: 'https://registry.npmjs.org'
2328

2429
- name: Install dependencies
2530
run: |
@@ -28,5 +33,3 @@ jobs:
2833
- name: Publish to NPM
2934
run: |
3035
bash ./bin/publish-npm
31-
env:
32-
NPM_TOKEN: ${{ secrets.KERNEL_NPM_TOKEN || secrets.NPM_TOKEN }}

.github/workflows/release-doctor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ jobs:
1717
- name: Check release environment
1818
run: |
1919
bash ./bin/check-release-environment
20-
env:
21-
NPM_TOKEN: ${{ secrets.KERNEL_NPM_TOKEN || secrets.NPM_TOKEN }}
2220

bin/check-release-environment

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
#!/usr/bin/env bash
22

3-
errors=()
4-
5-
if [ -z "${NPM_TOKEN}" ]; then
6-
errors+=("The NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
7-
fi
8-
9-
lenErrors=${#errors[@]}
10-
11-
if [[ lenErrors -gt 0 ]]; then
12-
echo -e "Found the following errors in the release environment:\n"
13-
14-
for error in "${errors[@]}"; do
15-
echo -e "- $error\n"
16-
done
17-
18-
exit 1
19-
fi
3+
# Publishing uses npm OIDC trusted publishers — no secrets required.
4+
# The GitHub Actions workflow must have `permissions: id-token: write`.
205

216
echo "The environment is ready to push releases!"
22-

bin/publish-npm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -eux
44

5-
npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN"
6-
75
yarn build
86
cd dist
97

@@ -57,5 +55,5 @@ else
5755
TAG="latest"
5856
fi
5957

60-
# Publish with the appropriate tag
61-
yarn publish --tag "$TAG"
58+
# Publish with the appropriate tag using npm OIDC trusted publishers
59+
npm publish --provenance --access public --tag "$TAG"

0 commit comments

Comments
 (0)