From bbc9a324d42878d278b99e5c79098e32c65b0e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E7=AB=A0=E6=B4=AA?= Date: Thu, 15 Oct 2026 11:04:43 +0800 Subject: [PATCH] ci(nodejs): skip npm publish when the version is already published npm refuses to publish over an existing version, so re-running the Release workflow (e.g. to retry another SDK's publish, as with the v5.2.1 Maven Central retry) failed publish-nodejs-sdk with E403 for every package. Check the main package version first, like the existing Maven Central / crates.io / PyPI guards, and skip the publish when it is already on npm. The main package is published last, so its presence means every platform package is published too. --- .github/workflows/release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e94413a210..aaf33fd877 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -787,7 +787,23 @@ jobs: run: ls -R ./npm shell: bash working-directory: ./nodejs + # npm refuses to publish over an existing version (E403), so a re-run of + # the release (e.g. to retry a different SDK's publish) would fail here. + # Skip when this version is already published. Only the main package is + # checked: it is published last, after every platform package. + - name: Check if version already on npm + run: | + version=$(node -p "require('./package.json').version") + if [ -n "$(npm view "longbridge@${version}" version 2>/dev/null)" ]; then + echo "longbridge ${version} already on npm; skipping publish." + echo "NPM_EXISTS=true" >> $GITHUB_ENV + else + echo "longbridge ${version} not found on npm; will publish." + echo "NPM_EXISTS=false" >> $GITHUB_ENV + fi + working-directory: ./nodejs - name: Publish + if: env.NPM_EXISTS != 'true' run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc npm publish --access public