Skip to content

Commit 0804896

Browse files
committed
chore: skip publish if version already exists
1 parent 9b7c431 commit 0804896

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.github/workflows/publish.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,22 @@ jobs:
3535
node-version: '24'
3636
registry-url: 'https://registry.npmjs.org'
3737

38+
# Check if version already published
39+
- name: Check if version exists
40+
id: version-check
41+
run: |
42+
PACKAGE_NAME=$(node -p "require('./package.json').name")
43+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
44+
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version 2>/dev/null; then
45+
echo "exists=true" >> $GITHUB_OUTPUT
46+
echo "Version ${PACKAGE_VERSION} already published, skipping..."
47+
else
48+
echo "exists=false" >> $GITHUB_OUTPUT
49+
echo "Version ${PACKAGE_VERSION} not found, will publish..."
50+
fi
51+
3852
# Trusted Publishing via OIDC - no token needed!
3953
# See: https://docs.npmjs.com/trusted-publishers/
4054
- name: Publish to npm
55+
if: steps.version-check.outputs.exists == 'false'
4156
run: npm publish --access public --provenance

0 commit comments

Comments
 (0)