Skip to content

Commit fcbe7cd

Browse files
vercel[bot]styfle
andauthored
ci: set up npm trusted publishing
Publish to npm via GitHub Actions OIDC instead of a long-lived NPM_TOKEN secret. - Bump semantic-release 17 -> 25, which pulls in @semantic-release/npm v13. OIDC token exchange landed in @semantic-release/npm v13.1.0, and v13 bundles npm 11.x (trusted publishing needs npm >= 11.5.1). - Move the release out of the test matrix into its own job so that `id-token: write` is scoped to the publish step only, and grant the permissions semantic-release needs now that the workflow declares an explicit permissions block. - Drop the NPM_TOKEN env var. With trusted publishing configured, @semantic-release/npm exchanges the Actions OIDC token for a short-lived registry token and never reads NPM_TOKEN. - Add publishConfig.access=public so the scoped package keeps publishing publicly, and bump CI to Node 22 because semantic-release v25 requires ^22.14.0 || >=24.10.0 (yarn v1 hard-fails on engine mismatch). Provenance attestations are generated automatically for public packages published from a public repo via OIDC, so no --provenance flag is needed. Co-Authored-By: Steven <229881+styfle@users.noreply.github.com>
1 parent 295d101 commit fcbe7cd

3 files changed

Lines changed: 2147 additions & 2973 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ on:
88
- "!*"
99
pull_request:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
test:
1316
name: Node ${{ matrix.node }} and ${{ matrix.os }}
1417
strategy:
1518
fail-fast: false
1619
matrix:
1720
os: [ubuntu-latest, macos-latest, windows-latest]
18-
node: [18]
21+
node: [22]
1922
runs-on: ${{ matrix.os }}
2023
steps:
2124
- uses: actions/checkout@v4
@@ -38,9 +41,28 @@ jobs:
3841
- name: Coverage
3942
if: matrix.os == 'ubuntu-latest'
4043
run: yarn test-coverage
44+
45+
release:
46+
name: Release
47+
needs: test
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write # to create the GitHub release and push the tag
52+
issues: write # to comment on released issues
53+
pull-requests: write # to comment on released pull requests
54+
id-token: write # to use OIDC for npm trusted publishing and provenance
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 0
59+
- name: Use Node.js
60+
uses: actions/setup-node@v4
61+
with:
62+
node-version: 22
63+
- name: Install Dependencies
64+
run: yarn install
4165
- name: Release
42-
if: matrix.os == 'ubuntu-latest' && matrix.node == 18 && github.event_name == 'push' && github.ref == 'refs/heads/main'
4366
env:
4467
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
4668
run: yarn semantic-release

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"files": [
1414
"src/*"
1515
],
16+
"publishConfig": {
17+
"access": "public"
18+
},
1619
"dependencies": {
1720
"@mapbox/node-pre-gyp": "^2.0.0",
1821
"acorn": "^8.3.0",
@@ -35,7 +38,7 @@
3538
"@vercel/ncc": "^0.38.1",
3639
"jest": "^26.6.3",
3740
"memory-fs": "^0.4.1",
38-
"semantic-release": "^17.3.0",
41+
"semantic-release": "^25.0.9",
3942
"socket.io-client": "^2.2.0",
4043
"webpack": "^5",
4144
"webpack-cli": "^4"

0 commit comments

Comments
 (0)