Skip to content

Commit b097905

Browse files
authored
ci: make npm publish step resumable after a failed publish (#399)
Gate Publish on whether the current package.json version is actually on npm, not on whether this run did a version bump. After a failed publish (e.g. missing npm trusted publisher config), a workflow_dispatch on the same commit will now fill the gap and push the missing version, instead of being skipped because commit-and-tag-version finds nothing new to bump. Idempotent on repeated runs.
1 parent 1272d78 commit b097905

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,30 @@ jobs:
7777
PREV=$(node -p "require('./package.json').version")
7878
bunx commit-and-tag-version
7979
NEXT=$(node -p "require('./package.json').version")
80+
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
8081
if [ "$PREV" = "$NEXT" ]; then
8182
echo "released=false" >> "$GITHUB_OUTPUT"
82-
echo "No release-worthy changes since last tag; skipping push and publish."
83+
echo "No release-worthy changes since last tag; will only publish if ${NEXT} is missing from npm."
8384
else
8485
echo "released=true" >> "$GITHUB_OUTPUT"
85-
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
86+
fi
87+
88+
- name: Check if current version is already on npm
89+
id: npm-check
90+
run: |
91+
VERSION="${{ steps.bump.outputs.version }}"
92+
if npm view "squel@${VERSION}" version >/dev/null 2>&1; then
93+
echo "needs_publish=false" >> "$GITHUB_OUTPUT"
94+
echo "squel@${VERSION} already on npm; skipping publish."
95+
else
96+
echo "needs_publish=true" >> "$GITHUB_OUTPUT"
97+
echo "squel@${VERSION} not on npm yet; will publish."
8698
fi
8799
88100
- name: Push release commit and tag
89101
if: steps.bump.outputs.released == 'true'
90102
run: git push --follow-tags origin HEAD:master
91103

92104
- name: Publish to npm
93-
if: steps.bump.outputs.released == 'true'
105+
if: steps.npm-check.outputs.needs_publish == 'true'
94106
run: npm publish --provenance --access public

0 commit comments

Comments
 (0)