Skip npm publish if already published

This helps make the publish workflow idempotent.
This commit is contained in:
Asher 2021-07-16 16:44:00 -05:00
parent 8608d8ec74
commit 3c0799fa59
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 8 additions and 0 deletions

View File

@ -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