Skip to content

Commit 1adb614

Browse files
ci: make npm/MCP-registry publish conditional — GitHub release + zips publish without NPM_TOKEN (advisory warning instead of blocking)
1 parent 0bfe50c commit 1adb614

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
version: ${{ steps.ver.outputs.version }}
4747
tag: ${{ steps.ver.outputs.tag }}
4848
npm_published: ${{ steps.npmcheck.outputs.already }}
49+
npm_has_token: ${{ steps.npm_auth.outputs.has_token }}
4950
steps:
5051
- uses: actions/checkout@v4
5152

@@ -125,25 +126,31 @@ jobs:
125126
done
126127
[ "$MISSING" = "0" ]
127128
128-
# Checked BEFORE anything is published. A missing NPM_TOKEN discovered
129-
# after the GitHub release is public is exactly the failure this workflow
130-
# is shaped to avoid.
131-
- name: npm authentication is available
129+
# npm is optional for the GitHub release. The GitHub release (zips) is
130+
# the primary deliverable; npm publish enhances distribution but should
131+
# not block a product release when the token is not yet configured.
132+
- name: npm authentication check (advisory)
133+
id: npm_auth
132134
env:
133135
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
134136
run: |
135137
if [ -z "$NODE_AUTH_TOKEN" ]; then
136-
echo "::error::NPM_TOKEN is not configured. Add it in Settings → Secrets and variables → Actions before releasing."
137-
exit 1
138+
echo "::warning::NPM_TOKEN is not configured — npm publish will be skipped (GitHub release + zips still published)."
139+
echo "has_token=false" >> "$GITHUB_OUTPUT"
140+
elif ! npm whoami >/dev/null 2>&1; then
141+
echo "::warning::NPM_TOKEN is set but not valid — npm publish will be skipped."
142+
echo "has_token=false" >> "$GITHUB_OUTPUT"
143+
else
144+
echo "npm authentication OK"
145+
echo "has_token=true" >> "$GITHUB_OUTPUT"
138146
fi
139-
npm whoami >/dev/null || { echo "::error::NPM_TOKEN is set but not valid for this registry"; exit 1; }
140-
echo "npm authentication OK"
141147
142148
# Republishing different bytes under an existing version is impossible on
143149
# npm and undesirable everywhere else, so detect it now and let the
144150
# publish step skip rather than fail.
145151
- name: Is this version already on npm?
146152
id: npmcheck
153+
if: steps.npm_auth.outputs.has_token == 'true'
147154
run: |
148155
V="${{ steps.ver.outputs.version }}"
149156
if [ -n "$(npm view "bridgistic-mcp-server@$V" version 2>/dev/null)" ]; then
@@ -244,7 +251,7 @@ jobs:
244251
echo "All artifacts match their recorded checksums."
245252
246253
- name: Publish to npm
247-
if: needs.preflight.outputs.npm_published != 'true'
254+
if: needs.preflight.outputs.npm_published != 'true' && needs.preflight.outputs.npm_has_token == 'true'
248255
env:
249256
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
250257
run: |
@@ -259,6 +266,7 @@ jobs:
259266
npm publish --access public "./release-artifacts/bridgistic-mcp-server-${V}.tgz"
260267
261268
- name: Publish to the MCP Registry
269+
if: needs.preflight.outputs.npm_has_token == 'true' && needs.preflight.outputs.npm_published != 'true'
262270
run: |
263271
curl -sSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_linux_amd64.tar.gz" | tar xz mcp-publisher
264272
./mcp-publisher login github-oidc

0 commit comments

Comments
 (0)