Skip to content

Commit 0224934

Browse files
pcarletonclaude
andcommitted
fix: use versioned npm tag for non-main branch releases
When publishing from maintenance branches (e.g., patch-1), use a major.minor tag like "v1.23" instead of defaulting to "latest". This prevents old patches from becoming the latest version on npm. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e98eece commit 0224934

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,18 @@ jobs:
6767
id: npm-tag
6868
run: |
6969
VERSION=$(node -p "require('./package.json').version")
70+
# Check if this is a beta release
7071
if [[ "$VERSION" == *"-beta"* ]]; then
7172
echo "tag=--tag beta" >> $GITHUB_OUTPUT
73+
# Check if this release is from a non-main branch (patch/maintenance release)
74+
elif [[ "${{ github.event.release.target_commitish }}" != "main" ]]; then
75+
# Use major.minor as tag for old branch releases (e.g., "v1.23" for 1.23.x)
76+
# npm tags are mutable pointers to versions (like "latest" pointing to 1.24.3).
77+
# Using "v1.23" means users can `npm install @modelcontextprotocol/sdk@v1.23`
78+
# to get the latest patch on that minor version, and the tag updates if we
79+
# release 1.23.2, 1.23.3, etc.
80+
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
81+
echo "tag=--tag v${MAJOR_MINOR}" >> $GITHUB_OUTPUT
7282
else
7383
echo "tag=" >> $GITHUB_OUTPUT
7484
fi

0 commit comments

Comments
 (0)