Skip to content

Commit 1fe2165

Browse files
ymansurozerclaude
andcommitted
ci: skip npm publish when the version is already on the registry
Makes the release job idempotent: if the package@version is already published (a manual bootstrap publish, or a re-run of a released tag), skip npm publish and still create the GitHub release instead of failing on "cannot publish over existing version". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj241sZMvCV2wAuH1A65Fm
1 parent 0906d23 commit 1fe2165

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ jobs:
2727
- run: pnpm smoke
2828
# OIDC trusted publishing (tokenless) requires npm >= 11.5.1
2929
- run: npm install -g npm@latest
30-
- run: npm publish --provenance --access public
30+
# Idempotent: skip when this exact version is already on the registry (e.g. a manual
31+
# bootstrap publish, or a re-run of a released tag) so the tag still produces the GitHub
32+
# release below instead of failing on "cannot publish over existing version".
33+
- run: |
34+
NAME=$(node -p "require('./package.json').name")
35+
VERSION=$(node -p "require('./package.json').version")
36+
if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
37+
echo "$NAME@$VERSION already published — skipping npm publish."
38+
else
39+
npm publish --provenance --access public
40+
fi
3141
- run: npx changelogen@latest github release --token "$GITHUB_TOKEN"
3242
env:
3343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)