Skip to content

Commit 6fe9137

Browse files
lex00claude
andauthored
ci(publish): use OIDC trusted publishing only (#42)
The maintainer is using GitHub OIDC trusted publishing, so drop the NPM_TOKEN fallback added in the prior PR — the publish job now matches chant's clean pure-OIDC step (id-token: write, no registry-url, npm publish --provenance, idempotent). README Releasing section updated. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 195e4d6 commit 6fe9137

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
permissions:
3636
contents: read
37-
id-token: write # OIDC trusted publishing (preferred; no secret needed)
38-
env:
39-
# Optional fallback for the FIRST publish: OIDC trusted publishing only
40-
# works once the package exists + a trusted-publisher record is configured
41-
# on npm. Before that, set an NPM_TOKEN repo/org secret and the workflow
42-
# publishes with it. Once trusted publishing is set up, drop the secret
43-
# and it falls through to OIDC automatically.
44-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
id-token: write # OIDC trusted publishing — no NPM_TOKEN secret needed
4538
steps:
4639
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
4740
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
@@ -51,23 +44,13 @@ jobs:
5144
# Deliberately NOT setting registry-url: that flag makes setup-node
5245
# write an .npmrc with `_authToken=${NODE_AUTH_TOKEN}`, and the token
5346
# defaults to a literal placeholder when unset — which the registry
54-
# 404s on instead of falling through to OIDC. We write .npmrc
55-
# ourselves below only when a token is actually present.
47+
# 404s on instead of falling through to OIDC. Without registry-url
48+
# there is no .npmrc; `npm publish` detects the OIDC id-token
49+
# environment and exchanges it for a short-lived publish token via the
50+
# package's trusted-publisher record.
5651
- run: npm ci
5752
- name: Publish github-warden
5853
run: |
59-
set -euo pipefail
6054
V=$(node -e "process.stdout.write(require('./package.json').version)")
6155
P=$(npm view github-warden version 2>/dev/null || echo "none")
62-
if [ "$V" = "$P" ]; then
63-
echo "github-warden@$V already published, skipping"
64-
exit 0
65-
fi
66-
if [ -n "${NPM_TOKEN:-}" ]; then
67-
echo "Publishing $V with NPM_TOKEN"
68-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
69-
npm publish --access public --provenance
70-
else
71-
echo "Publishing $V via OIDC trusted publishing"
72-
npm publish --access public --provenance
73-
fi
56+
[ "$V" = "$P" ] && echo "github-warden@$V already published, skipping" || npm publish --access public --provenance

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,10 @@ main) on a schedule, pinned to a warden Action SHA.
242242
and pushes — which triggers `.github/workflows/publish.yml` (test gate → `npm
243243
publish --provenance`).
244244

245-
npm auth is one of two modes (the workflow supports both):
246-
247-
- **OIDC trusted publishing** (preferred, no secret) — requires a one-time
248-
trusted-publisher record on npm for `github-warden` ← `intentius/github-warden`
249-
`publish.yml`. Works only after the package's first publish exists.
250-
- **`NPM_TOKEN` secret** (fallback) — set a repo/org `NPM_TOKEN` secret for the
251-
first publish; drop it once trusted publishing is configured.
245+
Publishing uses **GitHub OIDC trusted publishing** — no `NPM_TOKEN` secret. It
246+
requires a one-time trusted-publisher record on npm for `github-warden` ←
247+
`intentius/github-warden`'s `publish.yml` (the workflow already requests
248+
`id-token: write` and publishes with `--provenance`).
252249
253250
## Architecture
254251

0 commit comments

Comments
 (0)