From 2a620b178dd1f0cc7994c5222e4bbf72485c83ee Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Tue, 10 Mar 2026 09:46:14 -0300 Subject: [PATCH] fix(ci): skip npm publish if version already exists on npm registry Prevents E403 failures when a release event fires more than once for the same version (e.g. re-running a failed workflow or duplicate tag event). The publish step now checks whether the version is already on npm and exits cleanly with a warning instead of failing the workflow. --- .github/workflows/npm-publish.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 1f18fa41..1089ad4e 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -39,6 +39,13 @@ jobs: run: node scripts/prepublish.mjs - name: Publish to npm - run: npm publish --access public + run: | + VERSION=$(node -p "require('./package.json').version") + # Check if this version is already published — skip instead of failing with E403 + if npm view "omniroute@${VERSION}" version --silent 2>/dev/null | grep -q "^${VERSION}$"; then + echo "️⚠️ Version ${VERSION} is already published on npm — skipping." + exit 0 + fi + npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}