Skip to content

Commit 43c8db1

Browse files
committed
ci(release): skip publish if version already exists on npm
1 parent 15c9927 commit 43c8db1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@ jobs:
3434
env:
3535
PUID_SKIP_DATA_TESTS: "1"
3636

37+
- name: Check if version already published
38+
id: check_published
39+
run: |
40+
VERSION=$(node -p "require('./package.json').version")
41+
echo "Version: $VERSION"
42+
EXISTS=$(npm view puid-js versions --json | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{const v=JSON.parse(s); console.log(v.includes(process.env.VERSION)?'yes':'no')})")
43+
if [ "$EXISTS" = "yes" ]; then
44+
echo "Version $VERSION already on npm; skipping publish"
45+
echo "skip=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "skip=false" >> $GITHUB_OUTPUT
48+
fi
49+
env:
50+
VERSION: ${{ steps.meta.outputs.version }}
51+
3752
- name: Publish to npm (with provenance)
53+
if: steps.check_published.outputs.skip != 'true'
3854
run: npm publish --provenance --tag latest --access public
3955
env:
4056
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)