Skip to content

Commit 5803eed

Browse files
akutishevskyclaude
andcommitted
ci: publish to npm via trusted publishing
The v1.3.1 publish failed with a 403: "Two-factor authentication is required to publish this package but an automation token was specified". The token that published v1.3.0 is no longer accepted, as the npm restriction on 2FA-bypass tokens anticipated. Switch the npm step to trusted publishing (OIDC). Drop `registry-url:` on setup-node, the NPM_TOKEN credential check, and the NODE_AUTH_TOKEN env: with no token, the auth line setup-node writes into .npmrc would block the OIDC exchange (actions/setup-node#1551). Requires the trusted publisher registered on npmjs.com for akutishevsky/monobank-mcp-server, workflow publish.yml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c3f55cb commit 5803eed

1 file changed

Lines changed: 11 additions & 35 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,16 @@ jobs:
2424
- name: Checkout code
2525
uses: actions/checkout@v5
2626

27-
# `registry-url:` is what makes setup-node write
28-
# `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}` into .npmrc,
29-
# so it is required for token auth — NODE_AUTH_TOKEN does nothing
30-
# without it.
31-
#
32-
# It is also incompatible with npm trusted publishing: when the token
33-
# is empty, npm sees configured-but-blank auth, never attempts the
34-
# OIDC exchange, and dies with ENEEDAUTH (actions/setup-node#1551).
35-
# If you switch to OIDC later, delete this line AND the
36-
# NODE_AUTH_TOKEN env on the publish step — both, or neither works.
27+
# `registry-url:` is deliberately NOT set. It makes setup-node write
28+
# `//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}` into .npmrc;
29+
# with no token that expands to an empty string, npm treats it as
30+
# configured auth, never attempts the OIDC exchange, and fails with
31+
# ENEEDAUTH (actions/setup-node#1551). Publishing already defaults to
32+
# registry.npmjs.org, so nothing is lost.
3733
- name: Set up Node.js
3834
uses: actions/setup-node@v5
3935
with:
4036
node-version: "lts/*"
41-
registry-url: "https://registry.npmjs.org"
4237

4338
# The version lives in five places (package.json, package-lock.json,
4439
# manifest.json, both fields in server.json, and the McpServer
@@ -67,20 +62,6 @@ jobs:
6762
check "src/index.ts" "$(grep -oE 'version: "[^"]+"' src/index.ts | head -1 | sed -E 's/.*"(.*)"/\1/')"
6863
exit $fail
6964
70-
# An absent secret expands to an empty string rather than failing, and
71-
# npm then reports it ten steps later as a bare "ENEEDAUTH ... you need
72-
# to authorize this machine", which says nothing about the real cause.
73-
# Fail here instead, with the fix in the message.
74-
- name: Verify npm credentials are present
75-
env:
76-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
77-
run: |
78-
if [ -z "${NODE_AUTH_TOKEN}" ]; then
79-
echo "::error::The NPM_TOKEN secret is unset or empty. Create an npm Automation token (npmjs.com -> Access Tokens -> Generate New Token -> Automation) and add it under Settings -> Secrets and variables -> Actions as NPM_TOKEN."
80-
exit 1
81-
fi
82-
echo "NPM_TOKEN is present"
83-
8465
- name: Install mcp-publisher
8566
run: |
8667
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
@@ -115,23 +96,18 @@ jobs:
11596
echo "exists=false" >> "$GITHUB_OUTPUT"
11697
fi
11798
118-
# Authenticated with an npm Automation token. This is a stopgap: per
119-
# the 2026-07-08 npm changelog, tokens that bypass 2FA lose the
120-
# ability to publish directly in January 2027.
121-
#
122-
# To migrate to trusted publishing before then, register the publisher
123-
# at https://www.npmjs.com/package/monobank-mcp-server/access
99+
# Trusted publishing: npm exchanges the workflow's OIDC token for a
100+
# short-lived publish credential, so there is no secret to store or
101+
# rotate. Requires the trusted publisher registered at
102+
# https://www.npmjs.com/package/monobank-mcp-server/access
124103
# Organization or user: akutishevsky
125104
# Repository: monobank-mcp-server
126105
# Workflow filename: publish.yml
127106
# Environment name: (leave empty)
128-
# then delete the NPM_TOKEN secret, this `env:` block, the credential
129-
# check above, and `registry-url:` on the setup-node step.
107+
# Without it npm fails with a bare ENEEDAUTH.
130108
- name: Publish package to npm
131109
if: steps.npm_check.outputs.exists == 'false'
132110
run: npm publish --provenance --access public
133-
env:
134-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
135111

136112
# The registry validates that the npm package and version exist and
137113
# that its package.json carries a matching `mcpName`. npm's read path

0 commit comments

Comments
 (0)