@@ -30,10 +30,28 @@ jobs:
3030 run : bun run build
3131
3232 - name : Configure npm auth
33- run : echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
33+ env :
34+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
35+ run : |
36+ if [ -z "$NPM_TOKEN" ]; then
37+ echo "::error::NPM_TOKEN secret is not set. Add it with: gh secret set NPM_TOKEN --repo ${{ github.repository }}"
38+ exit 1
39+ fi
40+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
41+
42+ - name : Verify npm authentication
43+ run : |
44+ # Fail loudly here rather than letting each publish fail silently.
45+ if ! npm whoami >/dev/null 2>&1; then
46+ echo "::error::npm authentication failed. The NPM_TOKEN secret is missing, expired, or lacks publish rights to the @anyq scope."
47+ exit 1
48+ fi
49+ echo "Authenticated to npm as: $(npm whoami)"
3450
3551 - name : Publish all packages
3652 run : |
53+ set -uo pipefail
54+
3755 PACKAGES=(
3856 core
3957 memory
@@ -47,17 +65,46 @@ jobs:
4765 azure-servicebus
4866 )
4967
68+ published=()
69+ skipped=()
70+ failed=()
71+
5072 for pkg in "${PACKAGES[@]}"; do
51- echo "Publishing @anyq/$pkg..."
52- cd packages/$pkg
53- bun publish --access public --no-git-checks || echo "Failed or already published: @anyq/$pkg"
54- cd ../..
55- done
73+ name="@anyq/$pkg"
74+ version="$(node -p "require('./packages/$pkg/package.json').version")"
5675
57- - name : Publish Summary
58- run : |
59- echo "## Published Packages" >> $GITHUB_STEP_SUMMARY
60- echo "" >> $GITHUB_STEP_SUMMARY
61- for pkg in core memory redis-streams rabbitmq sqs sns google-pubsub kafka nats azure-servicebus; do
62- echo "- \`@anyq/$pkg\`" >> $GITHUB_STEP_SUMMARY
76+ # Idempotent: skip versions already on the registry so re-running a
77+ # tag does not hard-fail on packages that already published.
78+ if npm view "${name}@${version}" version >/dev/null 2>&1; then
79+ echo "Skipping ${name}@${version} (already on npm)"
80+ skipped+=("${name}@${version}")
81+ continue
82+ fi
83+
84+ echo "Publishing ${name}@${version}..."
85+ if ( cd "packages/$pkg" && bun publish --access public --no-git-checks ); then
86+ published+=("${name}@${version}")
87+ else
88+ echo "::error::Failed to publish ${name}@${version}"
89+ failed+=("${name}@${version}")
90+ fi
6391 done
92+
93+ {
94+ echo "## Publish results"
95+ echo ""
96+ echo "### Published (${#published[@]})"
97+ for p in "${published[@]:-}"; do [ -n "$p" ] && echo "- \`$p\`"; done
98+ echo ""
99+ echo "### Skipped, already on npm (${#skipped[@]})"
100+ for p in "${skipped[@]:-}"; do [ -n "$p" ] && echo "- \`$p\`"; done
101+ echo ""
102+ echo "### Failed (${#failed[@]})"
103+ for p in "${failed[@]:-}"; do [ -n "$p" ] && echo "- \`$p\`"; done
104+ } >> "$GITHUB_STEP_SUMMARY"
105+
106+ # Any real failure fails the job so a green check means a real release.
107+ if [ "${#failed[@]}" -gt 0 ]; then
108+ echo "::error::${#failed[@]} package(s) failed to publish: ${failed[*]}"
109+ exit 1
110+ fi
0 commit comments