Skip to content

Commit 07a2b4b

Browse files
cliffhallclaude
andauthored
ci: sync the release workflow on v2/main with main's verbatim (#1902) (#1904)
main's copy of .github/workflows/main.yml carried three release fixes v2/main never took -- #1831 (least-privilege default GITHUB_TOKEN scope), #1834 (derive the npm dist-tag from the version) and #1836 (publish via npm OIDC trusted publishing). Diffing the file both directions shows v2/main has NOTHING main lacks: its only unique content is the superseded publish step, run: npm publish --access public --provenance env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} which is exactly what #1836 replaced. Every other line already matched. So this is a verbatim copy of main's file rather than a hunk-by-hunk forward-port -- fewer ways to get it wrong, and it leaves the two branches byte-identical (`git diff origin/main -- .github/workflows` is now empty). Not a back-merge: only this one file is taken, so none of main's pre-swap v1 lineage enters v2/main's ancestry (see #1868). Claude-Session: https://claude.ai/code/session_01YAt8rqxysNbhYWLhoRm3fU Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 834fd2d commit 07a2b4b

1 file changed

Lines changed: 38 additions & 3 deletions

File tree

.github/workflows/main.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ on:
88
release:
99
types: [published]
1010

11+
# Default least-privilege scope for GITHUB_TOKEN. Without this, jobs inherit the
12+
# repository's default token permissions, which are broader than any job here
13+
# needs (CodeQL `actions/missing-workflow-permissions`). The `publish` and
14+
# `publish-github-container-registry` jobs declare their own blocks below, which
15+
# override this one entirely rather than adding to it — so each publish job must
16+
# continue to list every scope it needs, including `contents: read`.
17+
permissions:
18+
contents: read
19+
1120
jobs:
1221
build:
1322
runs-on: ubuntu-latest
@@ -145,6 +154,11 @@ jobs:
145154
exit 1
146155
fi
147156
157+
# OIDC trusted publishing requires npm >= 11.5.1; Node 22's bundled npm is
158+
# 10.x, which fails with ENEEDAUTH before OIDC is ever attempted.
159+
- name: Ensure npm CLI supports OIDC trusted publishing
160+
run: npm install -g npm@^11.5.1
161+
148162
- name: Install dependencies (root + all clients)
149163
run: npm install
150164

@@ -160,9 +174,30 @@ jobs:
160174
# prepack); the redundancy is intentional — each is a clean-tree rebuild
161175
# and the `prepack` one is what actually populates the published tarball,
162176
# so don't "optimize" it away.
163-
run: npm publish --access public --provenance
164-
env:
165-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
177+
#
178+
# The dist-tag is derived from the version, and passing it explicitly is
179+
# NOT optional: `npm publish` defaults to `--tag latest` regardless of
180+
# semver prerelease status, so publishing `2.0.0-rc.1` without this would
181+
# point every `npx @modelcontextprotocol/inspector` at a release
182+
# candidate. A prerelease is a hyphen after the patch component
183+
# (`2.0.0-rc.1`); build metadata uses `+` and is not a prerelease. Done
184+
# in shell rather than with `semver` because that package is only a
185+
# transitive dependency here and must not be relied on in CI.
186+
#
187+
# There is deliberately NO `NODE_AUTH_TOKEN` here. Publishing uses npm
188+
# OIDC trusted publishing (`id-token: write` + `environment: release`),
189+
# which needs no token — and the repo has no `NPM_TOKEN` secret. Setting
190+
# it from a non-existent secret writes an EMPTY `_authToken` into the
191+
# `.npmrc` that `setup-node` generates, and npm then fails `ENEEDAUTH`
192+
# before OIDC is ever attempted. Do not "restore" it.
193+
run: |
194+
VERSION="$(node -p "require('./package.json').version")"
195+
case "$VERSION" in
196+
*-*) NPM_TAG=next ;;
197+
*) NPM_TAG=latest ;;
198+
esac
199+
echo "Publishing $VERSION under dist-tag '$NPM_TAG'"
200+
npm publish --access public --provenance --tag "$NPM_TAG"
166201
167202
# Build and push the multi-arch container image to GHCR on a published
168203
# release. The image installs the packed tarball (`Dockerfile`) so it ships

0 commit comments

Comments
 (0)