Skip to content

Commit 57ddc0c

Browse files
authored
ci: migrate to npm trusted publishing (#1967)
- Add id-token: write permission for OIDC - Remove NPM_TOKEN dependency - Add --provenance flag to lerna publish This enables npm's trusted publishing using OpenID Connect, eliminating the need for long-lived npm tokens.
1 parent 4cefb36 commit 57ddc0c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
build:
1111
if: (!contains(github.event.head_commit.message, 'ci(release)'))
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
id-token: write
1316
strategy:
1417
fail-fast: true
1518

@@ -44,11 +47,8 @@ jobs:
4447

4548
- name: Publish to NPM
4649
if: github.ref == 'refs/heads/master'
47-
env:
48-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4950
run: |
50-
git reset --hard
51+
git reset --hard
5152
git config --global user.name ${{ secrets.GIT_USER }}
5253
git config --global user.email ${{ secrets.GIT_EMAIL }}
53-
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
5454
bash scripts/default-registry.sh

.github/workflows/graduate.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
jobs:
77
build_and_graduate:
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
id-token: write
912
strategy:
1013
fail-fast: true
1114

@@ -35,11 +38,8 @@ jobs:
3538
run: yarn ci
3639

3740
- name: Graduate beta release to NPM
38-
env:
39-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4041
run: |
41-
git reset --hard
42+
git reset --hard
4243
git config --global user.name ${{ secrets.GIT_USER }}
4344
git config --global user.email ${{ secrets.GIT_EMAIL }}
44-
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
45-
npm run graduate -- --yes
45+
npm run graduate -- --yes --provenance

scripts/default-registry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
#!/bin/bash
33

4-
yarn lerna publish --dist-tag=next --preid=beta --conventional-prerelease --yes
4+
yarn lerna publish --dist-tag=next --preid=beta --conventional-prerelease --yes --provenance

0 commit comments

Comments
 (0)