@@ -30,8 +30,8 @@ main() {
30
30
# a developer to install this version with `yarn add code-server@beta`
31
31
# "production" - this means we tag with `latest` (default), allowing
32
32
# a developer to install this version with `yarn add code-server@latest`
33
- if ! is_env_var_set " ENVIRONMENT " ; then
34
- echo " ENVIRONMENT is not set. Cannot determine npm tag without ENVIRONMENT ."
33
+ if ! is_env_var_set " NPM_ENVIRONMENT " ; then
34
+ echo " NPM_ENVIRONMENT is not set. Cannot determine npm tag without NPM_ENVIRONMENT ."
35
35
exit 1
36
36
fi
37
37
@@ -53,6 +53,12 @@ main() {
53
53
exit 1
54
54
fi
55
55
56
+ # We use this to grab the branch name
57
+ if ! is_env_var_set " GITHUB_REF_NAME" ; then
58
+ echo " GITHUB_REF_NAME is not set. Are you running this locally? We rely on values provided by GitHub."
59
+ exit 1
60
+ fi
61
+
56
62
# We use this when setting NPM_VERSION
57
63
if ! is_env_var_set " GITHUB_SHA" ; then
58
64
echo " GITHUB_SHA is not set. Are you running this locally? We rely on values provided by GitHub."
@@ -64,11 +70,12 @@ main() {
64
70
echo " //registry.npmjs.org/:_authToken=${NPM_TOKEN} " > ~ /.npmrc
65
71
fi
66
72
67
- # TODO@jsjoeio we need to refactor to download this based on environment
68
- # for "development", use the branch artifacts
69
- # for "staging" (merges into main),
70
- # for "production" look for release branch (currently we do this)
71
- download_artifact npm-package ./release-npm-package
73
+ # Note: if this runs on a push to main or a release workflow
74
+ # There is no BRANCH so branch will be empty which is why
75
+ # we set a default.
76
+ # Source:https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
77
+ BRANCH=" ${GITHUB_REF_NAME: main} "
78
+ download_artifact npm-package ./release-npm-package " $NPM_ENVIRONMENT " " $BRANCH "
72
79
# https://github.com/actions/upload-artifact/issues/38
73
80
tar -xzf release-npm-package/package.tar.gz
74
81
@@ -80,27 +87,27 @@ main() {
80
87
# We only need to run npm version for "development" and "staging".
81
88
# This is because our release:prep script automatically bumps the version
82
89
# in the package.json and we commit it as part of the release PR.
83
- if [[ " $ENVIRONMENT " == " production" ]]; then
90
+ if [[ " $NPM_ENVIRONMENT " == " production" ]]; then
84
91
NPM_VERSION=" $VERSION "
85
92
# This means the npm version will be published as "stable"
86
93
# and installed when a user runs `yarn install code-server`
87
94
NPM_TAG=" latest"
88
95
else
89
96
COMMIT_SHA=" $GITHUB_SHA "
90
97
echo " Not a production environment"
91
- echo " Found environment: $ENVIRONMENT "
98
+ echo " Found environment: $NPM_ENVIRONMENT "
92
99
echo " Manually bumping npm version..."
93
100
94
- if [[ " $ENVIRONMENT " == " beta" ]]; then
101
+ if [[ " $NPM_ENVIRONMENT " == " beta" ]]; then
95
102
NPM_VERSION=" $VERSION -beta-$COMMIT_SHA "
96
103
# This means the npm version will be tagged with "beta"
97
104
# and installed when a user runs `yarn install code-server@beta`
98
105
NPM_TAG=" beta"
99
106
fi
100
107
101
- if [[ " $ENVIRONMENT " == " development" ]]; then
108
+ if [[ " $NPM_ENVIRONMENT " == " development" ]]; then
102
109
# Source: https://github.com/actions/checkout/issues/58#issuecomment-614041550
103
- PR_NUMBER=$( echo $GITHUB_REF | awk ' BEGIN { FS = "/" } ; { print $3 }' )
110
+ PR_NUMBER=$( echo " $GITHUB_REF " | awk ' BEGIN { FS = "/" } ; { print $3 }' )
104
111
NPM_VERSION=" $VERSION -$PR_NUMBER -$COMMIT_SHA "
105
112
# This means the npm version will be tagged with "<pr number>"
106
113
# and installed when a user runs `yarn install code-server@<pr number>`
0 commit comments