Skip to content

Commit 227ec3c

Browse files
authored
ci: migrate to npm OIDC trusted publishing (#2261)
Replace NPM_TOKEN with OIDC authentication for npm publishing: - Add id-token permission for OIDC authentication - Upgrade to Node.js 22.x (includes npm with OIDC support) - Remove .npmrc creation step and NPM_TOKEN references - Add publishConfig with provenance to all published packages
1 parent 6bf8a7e commit 227ec3c

5 files changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/release-packages.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
branches:
66
- canary
77

8+
permissions:
9+
contents: write # For creating releases/tags
10+
pull-requests: write # For creating version PRs
11+
id-token: write # For npm OIDC authentication
12+
813
jobs:
914
release_packages:
1015
name: Release Packages
@@ -16,22 +21,15 @@ jobs:
1621
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1722
fetch-depth: 0
1823

19-
- name: Setup Node.js 18.x
24+
- name: Setup Node.js 22.x
2025
uses: actions/setup-node@v4
2126
with:
22-
node-version: 18.x
27+
node-version: 22.x
28+
registry-url: 'https://registry.npmjs.org'
2329

2430
- name: Install Dependencies
2531
run: npm ci
2632

27-
- name: Create .npmrc
28-
run: |
29-
cat << EOF > "$HOME/.npmrc"
30-
//registry.npmjs.org/:_authToken=$NPM_TOKEN
31-
EOF
32-
env:
33-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34-
3533
- name: Create Release Pull Request or Publish to npm
3634
id: changesets
3735
uses: changesets/action@v1
@@ -41,7 +39,6 @@ jobs:
4139
version: npm run version
4240
env:
4341
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4542
- name: Save Plugin version
4643
run: |
4744
json=${{ toJSON(steps.changesets.outputs.publishedPackages) }}

packages/block-editor-utils/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@
5858
"engines": {
5959
"node": ">=18",
6060
"npm": ">=8"
61+
},
62+
"publishConfig": {
63+
"access": "public",
64+
"provenance": true
6165
}
6266
}

packages/blocks/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@
4343
"engines": {
4444
"node": ">=18",
4545
"npm": ">=8"
46+
},
47+
"publishConfig": {
48+
"access": "public",
49+
"provenance": true
4650
}
4751
}

packages/faustwp-cli/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@
5959
"engines": {
6060
"node": ">=18",
6161
"npm": ">=8"
62+
},
63+
"publishConfig": {
64+
"access": "public",
65+
"provenance": true
6266
}
6367
}

packages/faustwp-core/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,9 @@
9898
"engines": {
9999
"node": ">=18",
100100
"npm": ">=8"
101+
},
102+
"publishConfig": {
103+
"access": "public",
104+
"provenance": true
101105
}
102106
}

0 commit comments

Comments
 (0)