ci(release): make the main-package publish step tolerant of 'npm view' 404
GitHub Actions runs shell steps with bash -e, so when npm view wickra@<v> returned exit 1 (because the package was not yet on the registry) the whole step aborted before reaching npm publish. Switch the step to `set +e` and capture the rc explicitly, so a 404 from npm view is treated as 'not published yet, go publish' instead of a fatal error. Also adds a single retry after 30s for spam-filter blocks.
This commit is contained in:
@@ -232,14 +232,27 @@ jobs:
|
|||||||
working-directory: bindings/node
|
working-directory: bindings/node
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
# GitHub Actions defaults to `bash -e`. `npm view` on a not-yet-
|
||||||
|
# published package returns 1, which would kill the step before
|
||||||
|
# we got to publish. Force a graceful empty result instead.
|
||||||
|
set +e
|
||||||
version=$(node -p "require('./package.json').version")
|
version=$(node -p "require('./package.json').version")
|
||||||
existing=$(npm view "wickra@$version" version 2>/dev/null)
|
existing=$(npm view "wickra@$version" version 2>/dev/null)
|
||||||
if [ "$existing" = "$version" ]; then
|
if [ "$existing" = "$version" ]; then
|
||||||
echo "::notice::skip wickra@$version (already on npm)"
|
echo "::notice::skip wickra@$version (already on npm)"
|
||||||
else
|
exit 0
|
||||||
npm publish --access public
|
|
||||||
fi
|
fi
|
||||||
|
npm publish --access public
|
||||||
|
rc=$?
|
||||||
|
if [ "$rc" -ne 0 ]; then
|
||||||
|
echo "::warning::first attempt failed (rc=$rc); retrying after 30s"
|
||||||
|
sleep 30
|
||||||
|
npm publish --access public
|
||||||
|
rc=$?
|
||||||
|
fi
|
||||||
|
exit $rc
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# WASM: wasm-pack build + npm publish (as `wickra-wasm`)
|
# WASM: wasm-pack build + npm publish (as `wickra-wasm`)
|
||||||
|
|||||||
Reference in New Issue
Block a user