publish: an NPM_TOKEN secret publishes what trusted publishing can't, a new package's first version and one with no Trusted Publisher, so nobody publishes by hand

Every publish run on main since 13:27 UTC 10-14 is red: opencode-zed-auth
0.1.7 and opencode-zen-free-auth 0.1.6 answer 404 because their Trusted
Publisher isn't set, and a new package (opendesign-auth, AstraFlow) can't be
created by OIDC at all. Each of those needed an org owner's OTP by hand.

npm tries OIDC first and falls back to the token in .npmrc, so publish.yml
now hands setup-node's NODE_AUTH_TOKEN the repository's NPM_TOKEN secret.
publish.sh publishes a new package when the token is there instead of
passing it by, and its errors say which of the two is missing or that the
token expired. The PR check now notes a new package instead of failing,
since the merge publishes it. README gains a Publishing section with the
one-time token setup.

Run: sh -n on both scripts; scripts/new-to-npm.sh against npm (every
package is on npm); scripts/publish.sh with GITHUB_ACTIONS=true and a fake
npm on PATH (zed-auth "new"): token -> published with the token, exit 0; no
token -> ::error naming it, exit 1; token refused -> ::error saying replace
the token, exit 1.
Not tried: a real publish with a token, since the secret doesn't exist yet.
This commit is contained in:
yetone
2026-10-15 01:58:21 +08:00
parent 9cfc18ae52
commit 4ef68fbf3f
5 changed files with 65 additions and 31 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# Checks a pull request before it is merged: the tests publish.yml runs, and
# that every package is on npm already (scripts/new-to-npm.sh). A new
# package merged first turned every publish run red (#39's block-patterns).
# names any package new to npm (scripts/new-to-npm.sh), which the merge
# publishes with the NPM_TOKEN secret.
name: pr
on:
@@ -31,5 +31,5 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 24
- name: every package is on npm
- name: packages new to npm
run: scripts/new-to-npm.sh
+9 -3
View File
@@ -1,7 +1,11 @@
# Publishes every package whose version isn't on npm yet, from GitHub
# Actions with npm's trusted publishing (OIDC): no token and no one-time
# password. Each package names this workflow as its trusted publisher on
# npmjs.com (package → Settings → Trusted Publisher).
# Actions. npm tries trusted publishing (OIDC) first: a package that names
# this workflow as its Trusted Publisher on npmjs.com needs nothing else.
# What OIDC can't do, the NPM_TOKEN secret does: a package's first version
# (trusted publishing can't create one) and a package whose Trusted
# Publisher isn't set. NPM_TOKEN is an npm granular access token of a
# magpie-community owner: read and write to the @magpie-community scope,
# 2FA bypassed. With it nobody publishes by hand.
name: publish
on:
@@ -31,3 +35,5 @@ jobs:
run: HOME=$(mktemp -d) bun test
- name: publish
run: scripts/publish.sh
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}