Skip to content

Commit 6834dc6

Browse files
BunsDevNova
andauthored
ci: skip duplicate npm publishes (#47) thanks @BunsDev
Avoid red duplicate npm publish runs when both the explicit dispatch and workflow_run fallback fire for the same release. Verification: - Ruby YAML parse for .github/workflows/npm-publish.yml - Local registry check for published 0.0.13 -> exists=true - Local registry check for fake 0.0.999999 -> exists=false - git diff --check Co-authored-by: Nova <nova@openclaw.local>
1 parent 65fe279 commit 6834dc6

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ permissions:
1919
# `workflow_run` is unreliable when the upstream `Release` run was itself
2020
# triggered by a GITHUB_TOKEN workflow_dispatch. If both paths happen to
2121
# fire for the same release, this static concurrency group serializes them
22-
# — the first one publishes, the second waits and then no-ops (or errors
23-
# benignly at `npm publish` because the version is already on the registry).
22+
# and the second run exits cleanly when the version is already on npm.
2423
# Releases are version-monotonic so blanket serialisation is safe; there
2524
# isn't a scenario where two concurrent publishes should both succeed.
2625
concurrency:
@@ -208,7 +207,22 @@ jobs:
208207
209208
cat npm/checksums.json
210209
210+
- name: Check whether version is already published
211+
id: registry_version
212+
env:
213+
VERSION: ${{ steps.version.outputs.version }}
214+
run: |
215+
set -euo pipefail
216+
if npm view "@opencoven/coven-code@$VERSION" version >/dev/null 2>&1; then
217+
echo "exists=true" >> "$GITHUB_OUTPUT"
218+
echo "@opencoven/coven-code@$VERSION is already published; skipping npm publish."
219+
else
220+
echo "exists=false" >> "$GITHUB_OUTPUT"
221+
echo "@opencoven/coven-code@$VERSION is not published yet; continuing."
222+
fi
223+
211224
- name: Publish to npm
225+
if: steps.registry_version.outputs.exists != 'true'
212226
working-directory: npm
213227
env:
214228
NODE_AUTH_TOKEN: ''

0 commit comments

Comments
 (0)