From 3c0799fa59e9a23eaee1b14f25b8aa104c7e6d9f Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 16 Jul 2021 16:44:00 -0500 Subject: [PATCH] Skip npm publish if already published This helps make the publish workflow idempotent. --- ci/steps/publish-npm.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci/steps/publish-npm.sh b/ci/steps/publish-npm.sh index 7bd497d0..ea65780d 100755 --- a/ci/steps/publish-npm.sh +++ b/ci/steps/publish-npm.sh @@ -5,6 +5,14 @@ main() { cd "$(dirname "$0")/../.." source ./ci/lib.sh + # npm view won't exit with non-zero so we have to check the output. + local hasVersion + hasVersion=$(npm view "code-server@$VERSION" version) + if [[ $hasVersion == "$VERSION" ]]; then + echo "$VERSION is already published" + return + fi + if [[ ${CI-} ]]; then echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc fi