Skip to content

Commit dd5a47a

Browse files
committed
ci: add version-already-published check to prevent npm 403
Skips npm publish if version already exists, so mcp-publisher step still runs on re-tags.
1 parent e5ebc3e commit dd5a47a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,22 @@ jobs:
3333
- name: Build (if applicable)
3434
run: npm run build --if-present
3535

36+
- name: Check if version already published
37+
id: check
38+
run: |
39+
PKG_NAME=$(node -p "require('./package.json').name")
40+
PKG_VER=$(node -p "require('./package.json').version")
41+
PUBLISHED=$(npm view "$PKG_NAME@$PKG_VER" version 2>/dev/null || echo "")
42+
if [ "$PUBLISHED" = "$PKG_VER" ]; then
43+
echo "skip=true" >> $GITHUB_OUTPUT
44+
else
45+
echo "skip=false" >> $GITHUB_OUTPUT
46+
fi
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49+
3650
- name: Publish to npm
51+
if: steps.check.outputs.skip != 'true'
3752
run: npm publish --access public
3853
env:
3954
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)