Files
plugins/scripts/new-to-npm.sh
T
yetone 4ef68fbf3f 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.
2026-10-15 01:58:21 +08:00

21 lines
807 B
Bash
Executable File

#!/bin/sh
# Names any package here that has never been published to npm. Trusted
# publishing can't create a package; publish.yml does it with the NPM_TOKEN
# secret when the pull request is merged (README, Publishing). A pull
# request runs this so the reviewer knows a merge publishes a new name.
set -e
cd "$(dirname "$0")/.."
export npm_config_registry=https://registry.npmjs.org
for dir in packages/*/; do
name=$(node -p "require('./${dir}package.json').name")
if [ "$(npm view "$name" name 2>/dev/null)" != "$name" ]; then
echo "::notice file=${dir}package.json::$name is not on npm yet. Merging publishes its first version with the NPM_TOKEN secret (README, Publishing)."
new="$new $name"
fi
done
if [ -n "$new" ]; then
echo "new to npm:$new"
else
echo "every package is on npm"
fi