From d62951d350f29decaed488d0635d0863de506586 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Sat, 18 Jan 2025 02:56:42 -0500 Subject: [PATCH] ci: update npm publish workflow to check for existing version before publishing; bump version to 0.0.8 --- .github/workflows/npm-publish.yml | 18 +++++++++++++++++- package.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index daaab3e..c148658 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -4,6 +4,8 @@ name: NPM Package Publish on: + push: + branches: [ main ] release: types: [created] workflow_dispatch: @@ -31,6 +33,20 @@ jobs: with: node-version: 22 registry-url: https://registry.npmjs.org/ - - run: npm publish --provenance --access public + - run: | + PACKAGE_NAME=$(jq -r '.name' package.json) + PACKAGE_VERSION=$(jq -r '.version' package.json) + + # Get the version from npm registry + REGISTRY_VERSION=$(npm show "$PACKAGE_NAME" version) + + # Compare versions + if [ "$PACKAGE_VERSION" == "$REGISTRY_VERSION" ]; then + echo "Version $PACKAGE_VERSION already exists in the npm registry." + exit 0 + else + echo "Version $PACKAGE_VERSION does not exist in the npm registry. Proceeding..." + npm publish --provenance --access public + fi env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/package.json b/package.json index 946ea1f..d672e25 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "kunkun-ext-git-skyline", "repository": "https://github.com/kunkunsh/kunkun-ext-git-skyline", "private": false, - "version": "0.0.7", + "version": "0.0.8", "type": "module", "scripts": { "dev": "vite",