Skip to content

Commit 7ca2c38

Browse files
lxcidclaude
andcommitted
chore: publish via npm trusted publishing instead of a token
Switches the release workflow to OIDC trusted publishing: no NPM_TOKEN secret to create or rotate, and provenance comes from npm's verified link to this repo and workflow. Requires npm >= 11.5.1 on the runner (Node 22 bundles npm 10), hence the upgrade step; id-token: write was already present. changesets/action supports token-less publishing (changesets/action#542). Because npm only allows configuring a trusted publisher on an existing package, CONTRIBUTING documents the one-time bootstrap: publish the first release manually, add the trusted publisher, and every later release is automatic. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent c31ba68 commit 7ca2c38

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ jobs:
2525
node-version: "22"
2626
cache: pnpm
2727
- run: pnpm install --frozen-lockfile
28+
# npm trusted publishing (OIDC via the id-token permission above)
29+
# needs npm >= 11.5.1; Node 22 bundles npm 10.
30+
- run: npm install --global npm@latest
2831
- run: pnpm test
2932
# Validate the tarball in this job, not just in the concurrent CI
3033
# workflow, so a publish can never race ahead of the check.
3134
- run: pnpm run check-pack
3235
# Opens/updates a "Version Packages" PR when changesets are pending;
33-
# publishes to npm (with provenance, per publishConfig) once that PR
34-
# merges. Requires an NPM_TOKEN repository secret from a 2FA-enabled
35-
# npm account.
36+
# publishes to npm once that PR merges. Publishing authenticates via
37+
# npm trusted publishing — no NPM_TOKEN secret — and provenance is
38+
# generated automatically. One-time bootstrap: the package must exist
39+
# on npm before a trusted publisher can be configured, so the FIRST
40+
# release is published manually (see CONTRIBUTING.md).
3641
- uses: changesets/action@v1
3742
with:
3843
publish: pnpm changeset publish
3944
env:
4045
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

‎CONTRIBUTING.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ Releases are managed with [changesets](https://github.com/changesets/changesets)
4343
1. Every user-facing change lands with a changeset (`pnpm changeset`).
4444
2. The `release` workflow opens a “Version Packages” PR that accumulates
4545
pending changesets; merging it publishes to npm with provenance.
46-
Publishing requires an `NPM_TOKEN` secret from a 2FA-enabled npm account.
47-
3. For pre-releases, enter pre mode first: `pnpm changeset pre enter alpha`,
46+
Publishing authenticates with
47+
[npm trusted publishing](https://docs.npmjs.com/trusted-publishers)
48+
(OIDC) — there is no npm token to manage.
49+
3. One-time bootstrap, because npm only lets you configure a trusted
50+
publisher on an existing package: after merging the first Version
51+
Packages PR, publish manually from a clean checkout of `main`
52+
(`pnpm install && pnpm test && npm publish`, with your 2FA device), then
53+
add the trusted publisher in the package's npm settings — repository
54+
`lxcid/remark-wikilink`, workflow `release.yml` (case-sensitive, filename
55+
only). Every later release is automatic.
56+
4. For pre-releases, enter pre mode first: `pnpm changeset pre enter alpha`,
4857
merge the version PR (versions like `0.1.0-alpha.0`), and validate the
4958
alpha in a real consumer before `pnpm changeset pre exit` and the stable
5059
release.

0 commit comments

Comments
 (0)