Skip to content

Commit 53d843c

Browse files
committed
chore: update npm publishing configuration and add version existence check in workflow
1 parent aad9a76 commit 53d843c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,20 @@ jobs:
7676
INPUT_VERSION: ${{ inputs.version }}
7777
run: npm version "$INPUT_VERSION" --no-git-tag-version
7878

79+
- name: Check if version already exists on npm
80+
id: check_version
81+
run: |
82+
PKG_VERSION=$(node -p "require('./package.json').version")
83+
if npm view "$(node -p "require('./package.json').name")@${PKG_VERSION}" version >/dev/null 2>&1; then
84+
echo "exists=true" >> "$GITHUB_OUTPUT"
85+
echo "Version ${PKG_VERSION} already exists on npm, skipping publish"
86+
else
87+
echo "exists=false" >> "$GITHUB_OUTPUT"
88+
echo "Version ${PKG_VERSION} does not exist on npm, will publish"
89+
fi
90+
7991
- name: Publish to npm
92+
if: steps.check_version.outputs.exists == 'false'
8093
env:
8194
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8295
NPM_DIST_TAG: ${{ inputs.tag }}
@@ -113,7 +126,6 @@ jobs:
113126
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
114127
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
115128
116-
117129
- name: Create GitHub Release
118130
uses: actions/github-script@v7
119131
if: ${{ github.event_name != 'release' }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"tagName": "v${version}"
116116
},
117117
"npm": {
118-
"publish": true
118+
"publish": false
119119
},
120120
"github": {
121121
"release": true

0 commit comments

Comments
 (0)