Skip to content

Commit e39ef2f

Browse files
committed
Configure package and release workflow for trusted publishing
1 parent b720ef3 commit e39ef2f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
matrix:
3737
os: [ ubuntu-latest ]
3838
node-version: [ 20.x ]
39+
permissions:
40+
id-token: write # For trusted publishing to npm (includes provenance)
41+
contents: write # For GitHub pages and creating release PRs
3942
steps:
4043
- uses: actions/checkout@v4
4144
with:
@@ -50,6 +53,14 @@ jobs:
5053
run: |
5154
pnpm install --frozen-lockfile
5255
56+
# NPM trusted publishing requires npm CLI v11.5.1+. Node.js 22 ships with
57+
# npm 10.x, so we need to upgrade. Note that pnpm uses npm under the hood
58+
# for publishes.
59+
- name: Upgrade npm for OIDC support
60+
run: |
61+
npm install -g npm@latest
62+
echo "✅ npm upgraded to $(npm --version)"
63+
5364
- name: Create Release Pull Request or Publish to npm
5465
id: changesets
5566
uses: changesets/action@v1
@@ -61,4 +72,9 @@ jobs:
6172
# the account of someone with appropriate access levels and given the
6273
# repo scope.
6374
GITHUB_TOKEN: ${{ secrets.KHAN_ACTIONS_BOT_TOKEN }}
64-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
75+
# NPM_CONFIG_PROVENANCE is for trusted publishing. We set this so
76+
# that (p)npm publish will include the provenance information in the
77+
# package.json file and surface it in the npm registry. See:
78+
# - https://docs.npmjs.com/generating-provenance-statements
79+
# - https://khanacademy.atlassian.net/wiki/spaces/FRONTEND/blog/4432363720/npm+Trusted+Publishing
80+
NPM_CONFIG_PROVENANCE: true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"url": "https://github.com/Khan/format-claude-stream/issues"
1111
},
1212
"publishConfig": {
13-
"access": "public"
13+
"access": "public",
14+
"provenance": true
1415
},
1516
"bin": "cli/main.ts",
1617
"main": "dist/index.js",

0 commit comments

Comments
 (0)