Skip to content

Commit 5dd5b00

Browse files
fix(ci): make publish workflow resilient to partial failures
Add version-exists checks so re-running a failed publish skips already-published packages instead of failing with 409 Conflict. - Check main package before publish steps; if already on npm, skip both platform and main publish (post-publish steps still run) - Check each platform package individually before npm publish; skip with continue if already published
1 parent f9f82d5 commit 5dd5b00

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,23 @@ jobs:
175175
with:
176176
path: artifacts/
177177

178-
- name: Verify version not already on npm
178+
- name: Check if main package already published
179+
id: check-main
179180
env:
180181
VERSION: ${{ needs.compute-version.outputs.version }}
181182
run: |
182183
PKG="@optave/codegraph"
183184
echo "Checking if $PKG@$VERSION already exists on npm..."
184185
if npm view "$PKG@$VERSION" version 2>/dev/null; then
185-
echo "::error::$PKG@$VERSION is already published on npm."
186-
exit 1
186+
echo "⚠️ $PKG@$VERSION is already published — will skip publish steps"
187+
echo "already_published=true" >> "$GITHUB_OUTPUT"
188+
else
189+
echo "$PKG@$VERSION is not yet published — proceeding"
190+
echo "already_published=false" >> "$GITHUB_OUTPUT"
187191
fi
188-
echo "$PKG@$VERSION is not yet published — proceeding"
189192
190193
- name: Publish platform packages
194+
if: steps.check-main.outputs.already_published == 'false'
191195
env:
192196
VERSION: ${{ needs.compute-version.outputs.version }}
193197
NPM_TAG: ${{ needs.compute-version.outputs.npm_tag }}
@@ -226,11 +230,18 @@ jobs:
226230
}
227231
PKGJSON
228232
233+
# Skip if this exact version is already published (idempotent re-runs)
234+
if npm view "${pkg_name}@${VERSION}" version 2>/dev/null; then
235+
echo "⚠️ ${pkg_name}@${VERSION} already published — skipping"
236+
continue
237+
fi
238+
229239
echo "Publishing ${pkg_name}@${VERSION} with --tag ${NPM_TAG}"
230240
npm publish "./pkg/$platform" --access public --provenance --tag "$NPM_TAG"
231241
done
232242
233243
- name: Publish main package
244+
if: steps.check-main.outputs.already_published == 'false'
234245
env:
235246
NPM_TAG: ${{ needs.compute-version.outputs.npm_tag }}
236247
run: npm publish --access public --provenance --tag "$NPM_TAG"

0 commit comments

Comments
 (0)