@@ -65,15 +65,15 @@ main() {
6565 # "production" - this means we tag with `latest` (default), allowing
6666 # a developer to install this version with `yarn add code-server@latest`
6767 if ! is_env_var_set " NPM_ENVIRONMENT" ; then
68- echo " NPM_ENVIRONMENT is not set. Determining in script based on GITHUB environment variables."
68+ echo " NPM_ENVIRONMENT is not set."
69+ echo " Determining in script based on GITHUB environment variables."
6970
7071 if [[ " $GITHUB_EVENT_NAME " == ' push' && " $GITHUB_REF " == ' refs/heads/main' ]]; then
7172 NPM_ENVIRONMENT=" staging"
7273 else
7374 NPM_ENVIRONMENT=" development"
7475 fi
7576
76- echo " Using npm environment: $NPM_ENVIRONMENT "
7777 fi
7878
7979 # NOTE@jsjoeio - this script assumes we have the artifact downloaded on disk
@@ -96,9 +96,6 @@ main() {
9696 NPM_TAG=" latest"
9797 else
9898 COMMIT_SHA=" $GITHUB_SHA "
99- echo " Not a production environment"
100- echo " Found environment: $NPM_ENVIRONMENT "
101- echo " Manually bumping npm version..."
10299
103100 if [[ " $NPM_ENVIRONMENT " == " staging" ]]; then
104101 NPM_VERSION=" $VERSION -beta-$COMMIT_SHA "
@@ -117,8 +114,10 @@ main() {
117114 NPM_TAG=" $PR_NUMBER "
118115 fi
119116
120- echo " using tag: $NPM_TAG "
121- echo " using package name: $PACKAGE_NAME "
117+ echo " - tag: $NPM_TAG "
118+ echo " - version: $NPM_VERSION "
119+ echo " - package name: $PACKAGE_NAME "
120+ echo " - npm environment: $NPM_ENVIRONMENT "
122121
123122 # We modify the version in the package.json
124123 # to be the current version + the PR number + commit SHA
@@ -140,13 +139,13 @@ main() {
140139 popd
141140 fi
142141
142+ # NOTE@jsjoeio
143143 # We need to make sure we haven't already published the version.
144- # This is because npm view won't exit with non-zero so we have
145- # to check the output.
144+ # If we get error, continue with script because we want to publish
145+ # If version is valid, we check if we're publishing the same one
146146 local hasVersion
147- hasVersion=$( npm view " code-server@$NPM_VERSION " version)
148- if [[ $hasVersion == " $NPM_VERSION " ]]; then
149- echo " $NPM_VERSION is already published"
147+ if hasVersion=$( npm view " $PACKAGE_NAME @$NPM_VERSION " version 2> /dev/null) && [[ $hasVersion == " $NPM_VERSION " ]]; then
148+ echo " $NPM_VERSION is already published under $PACKAGE_NAME "
150149 return
151150 fi
152151
0 commit comments