Skip to content

Commit 81befa3

Browse files
committed
ci: harden release with OIDC trusted publishing (no tokens), drop PAT
Replaces the PAT-based approach with npm Trusted Publishing (OIDC), mirroring TanStack's release flow. This removes long-lived publishing secrets entirely and addresses the security review findings. - npm auth via OIDC: add .npmrc provenance=true + id-token:write, and remove the NPM_TOKEN secret usage. Requires a trusted publisher to be configured for react-router-devtools on npmjs.com. - Drop the RELEASE_GITHUB_TOKEN PAT; the changesets action uses only the ephemeral GITHUB_TOKEN (to open the Release PR + create GH releases). - Pin all action versions to commit SHAs (supply-chain hardening). - Guard the job to this repo + main only (covers workflow_dispatch), so a dispatch can never publish from a non-main ref or a fork. - Pin Node 24 (npm 11) so OIDC works if pnpm delegates to npm publish. - Drop unused actions:write permission; add concurrency (no cancel). - Keep workflow_dispatch as a guarded manual recovery valve.
1 parent 3b17321 commit 81befa3

2 files changed

Lines changed: 63 additions & 48 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,62 @@
1-
name: Release
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
jobs:
9-
release:
10-
name: Release
11-
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
14-
pull-requests: write
15-
actions: write
16-
id-token: write
17-
steps:
18-
- name: Checkout Repo
19-
uses: actions/checkout@v3
20-
21-
- name: Install pnpm
22-
uses: pnpm/action-setup@v4
23-
24-
- name: Setup Node.js
25-
uses: actions/setup-node@v3
26-
with:
27-
node-version-file: "package.json"
28-
29-
- name: Install Dependencies
30-
run: pnpm install
31-
32-
# - name: 🔐 Setup npm auth
33-
# run: |
34-
# echo "registry=https://registry.npmjs.org" >> ~/.npmrc
35-
# echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
36-
37-
- name: Create Release Pull Request or Publish to npm
38-
id: changesets
39-
uses: changesets/action@v1
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
43-
with:
44-
title: "🚀 Release PR"
45-
commit: "chore: release"
46-
version: pnpm run version
47-
publish: pnpm run release
48-
createGithubReleases: true
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Manual safety valve: re-run publish for a version that was bumped but never
8+
# published. Guarded below so a dispatch can only ever publish from main.
9+
workflow_dispatch:
10+
11+
concurrency:
12+
# Never cancel an in-progress release; queue concurrent runs instead.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
permissions:
17+
contents: write # push the version PR branch, create tags + GitHub releases
18+
pull-requests: write # open/update the changesets "Release PR"
19+
id-token: write # npm Trusted Publishing (OIDC) — no long-lived NPM_TOKEN needed
20+
21+
jobs:
22+
release:
23+
name: Release
24+
# Don't run on forks; only ever publish from main (incl. workflow_dispatch).
25+
if: github.repository_owner == 'code-forge-io' && github.ref == 'refs/heads/main'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout Repo
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
with:
31+
fetch-depth: 0
32+
# Required so changesets/action can push the version PR branch. Only the
33+
# ephemeral GITHUB_TOKEN is persisted (auto-expires at job end) — no PAT.
34+
persist-credentials: true
35+
36+
- name: Install pnpm
37+
uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7
38+
39+
- name: Setup Node.js
40+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
41+
with:
42+
# Pin to Node 24 (ships npm 11.x) so OIDC Trusted Publishing works even
43+
# if pnpm delegates publishing to npm. npm OIDC needs >= 11.5.1.
44+
node-version: "24"
45+
46+
- name: Install Dependencies
47+
run: pnpm install
48+
49+
- name: Create Release Pull Request or Publish to npm
50+
id: changesets
51+
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
52+
env:
53+
# Only used to open/update the Release PR and create GitHub releases.
54+
# npm authentication is handled by OIDC Trusted Publishing (.npmrc
55+
# provenance=true + id-token:write) — there is intentionally no NPM_TOKEN.
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
title: "🚀 Release PR"
59+
commit: "chore: release"
60+
version: pnpm run version
61+
publish: pnpm run release
62+
createGithubReleases: true

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
provenance=true

0 commit comments

Comments
 (0)