From cc20fcaba98691aa8d351b75fe9188ed576bb2ba Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 3 Oct 2026 15:18:18 +0800 Subject: [PATCH] =?UTF-8?q?publish:=20a=20package=20npm=20has=20never=20se?= =?UTF-8?q?en=20no=20longer=20stops=20the=20rest=20=E2=80=94=20trusted=20p?= =?UTF-8?q?ublishing=20can't=20create=20a=20package,=20so=20trae-auth=200.?= =?UTF-8?q?1.0's=20PUT=20came=20back=20404=20(run=2037104702928)=20and=20s?= =?UTF-8?q?et=20-e=20would=20have=20left=20every=20package=20after=20it=20?= =?UTF-8?q?(workbuddy,=20zcode,=20zed)=20unpublished=20on=20their=20next?= =?UTF-8?q?=20bump.=20In=20Actions=20a=20new=20package=20is=20passed=20by?= =?UTF-8?q?=20with=20an=20error=20naming=20the=20way=20out=20(its=20first?= =?UTF-8?q?=20version=20by=20hand=20with=20scripts/publish.sh=20,=20t?= =?UTF-8?q?hen=20this=20workflow=20as=20its=20Trusted=20Publisher),=20the?= =?UTF-8?q?=20rest=20are=20published,=20and=20the=20run=20fails=20at=20the?= =?UTF-8?q?=20end=20naming=20it.=20Tried=20with=20a=20stubbed=20npm=20publ?= =?UTF-8?q?ish:=20zed=20bumped=20publishes=20after=20trae=20is=20passed=20?= =?UTF-8?q?by,=20exit=201.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/publish.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/publish.sh b/scripts/publish.sh index 9aa1d4d..b9bb4cf 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -4,6 +4,11 @@ # GitHub Actions runs it with no password on each version bump pushed to # main (.github/workflows/publish.yml, npm's trusted publishing). # One password covers the lot: it is sent with each publish while it lasts. +# Trusted publishing can't make a package npm has never seen: a new one's +# first version goes by hand (an npm account of the magpie-community org, +# `scripts/publish.sh `), and its Trusted Publisher is set after. Till +# then Actions passes it by, publishes the rest, and fails at the end +# naming it. set -e cd "$(dirname "$0")/.." # npm's own registry, whatever ~/.npmrc names (a mirror such as npmmirror @@ -18,5 +23,14 @@ for dir in packages/*/; do echo "= $name@$version is on npm already" continue fi + if [ -n "$GITHUB_ACTIONS" ] && [ -z "$otp" ] && ! npm view "$name" name >/dev/null 2>&1; then + echo "::error::$name is not on npm yet: trusted publishing can't create it. Publish its first version by hand (scripts/publish.sh ), then set this workflow as its Trusted Publisher on npmjs.com." + new="$new $name" + continue + fi (cd "$dir" && npm publish --access public ${otp:+--otp="$otp"}) done +if [ -n "$new" ]; then + echo "not published, new to npm:$new" + exit 1 +fi