@@ -65,15 +65,15 @@ main() {
65
65
# "production" - this means we tag with `latest` (default), allowing
66
66
# a developer to install this version with `yarn add code-server@latest`
67
67
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."
69
70
70
71
if [[ " $GITHUB_EVENT_NAME " == ' push' && " $GITHUB_REF " == ' refs/heads/main' ]]; then
71
72
NPM_ENVIRONMENT=" staging"
72
73
else
73
74
NPM_ENVIRONMENT=" development"
74
75
fi
75
76
76
- echo " Using npm environment: $NPM_ENVIRONMENT "
77
77
fi
78
78
79
79
# NOTE@jsjoeio - this script assumes we have the artifact downloaded on disk
@@ -96,9 +96,6 @@ main() {
96
96
NPM_TAG=" latest"
97
97
else
98
98
COMMIT_SHA=" $GITHUB_SHA "
99
- echo " Not a production environment"
100
- echo " Found environment: $NPM_ENVIRONMENT "
101
- echo " Manually bumping npm version..."
102
99
103
100
if [[ " $NPM_ENVIRONMENT " == " staging" ]]; then
104
101
NPM_VERSION=" $VERSION -beta-$COMMIT_SHA "
@@ -117,8 +114,10 @@ main() {
117
114
NPM_TAG=" $PR_NUMBER "
118
115
fi
119
116
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 "
122
121
123
122
# We modify the version in the package.json
124
123
# to be the current version + the PR number + commit SHA
@@ -140,13 +139,13 @@ main() {
140
139
popd
141
140
fi
142
141
142
+ # NOTE@jsjoeio
143
143
# 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
146
146
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 "
150
149
return
151
150
fi
152
151
0 commit comments