From da1488c9671a337ed775da288fb1aa2043bb939d Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Sat, 18 Nov 2023 11:17:59 +0800 Subject: [PATCH] if publish fails, try again in 60s if two publishes happen simultaneously (such as default branch and tag branch) then one will fail --- action.bash | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/action.bash b/action.bash index 12737e0..b25b19c 100755 --- a/action.bash +++ b/action.bash @@ -91,7 +91,11 @@ if test -n "${REPO_TAG-}" -o -n "${tag-}"; then next="${version%-*}-${tag}.${time}.${REPO_SHA}" # version trims anything after - npm version "${next}" --git-tag-version=false echo "publishing branch ${branch} to tag ${tag} with version ${next}..." - npm publish --access public --tag "${tag}" + npm publish --access public --tag "${tag}" || { + echo "trying again in 60s..." + sleep 60 + npm publish --access public --tag "${tag}" + } # publish package.json else @@ -128,7 +132,11 @@ if test -n "${BEVRY_CDN_TOKEN-}"; then npm version "${cdn}" --git-tag-version=false echo "publishing to tag ${tag} with version ${cdn}..." - npm publish --access public --tag "${tag}" + npm publish --access public --tag "${tag}" || { + echo "trying again in 60s..." + sleep 60 + npm publish --access public --tag "${tag}" + } echo "adding cdn aliases..." packageName="$(node -e "process.stdout.write(require('./package.json').name)")"