@@ -21,20 +21,6 @@ main() {
21
21
exit 1
22
22
fi
23
23
24
- # # Environment
25
- # This string is used to determine how we should tag the npm release.
26
- # Environment can be one of three choices:
27
- # "development" - this means we tag with the PR number, allowing
28
- # a developer to install this version with `yarn add code-server@<pr-number>`
29
- # "staging" - this means we tag with `beta`, allowing
30
- # a developer to install this version with `yarn add code-server@beta`
31
- # "production" - this means we tag with `latest` (default), allowing
32
- # a developer to install this version with `yarn add code-server@latest`
33
- if ! is_env_var_set " NPM_ENVIRONMENT" ; then
34
- echo " NPM_ENVIRONMENT is not set. Cannot determine npm tag without NPM_ENVIRONMENT."
35
- exit 1
36
- fi
37
-
38
24
# # Publishing Information
39
25
# All the variables below are used to determine how we should publish
40
26
# the npm package. We also use this information for bumping the version.
@@ -59,11 +45,38 @@ main() {
59
45
exit 1
60
46
fi
61
47
48
+ # We use this to determine the NPM_ENVIRONMENT
49
+ if ! is_env_var_set " GITHUB_EVENT_NAME" ; then
50
+ echo " GITHUB_EVENT_NAME is not set. Are you running this locally? We rely on values provided by GitHub."
51
+ exit 1
52
+ fi
53
+
62
54
# This allows us to publish to npm in CI workflows
63
55
if [[ ${CI-} ]]; then
64
56
echo " //registry.npmjs.org/:_authToken=${NPM_TOKEN} " > ~ /.npmrc
65
57
fi
66
58
59
+ # # Environment
60
+ # This string is used to determine how we should tag the npm release.
61
+ # Environment can be one of three choices:
62
+ # "development" - this means we tag with the PR number, allowing
63
+ # a developer to install this version with `yarn add code-server@<pr-number>`
64
+ # "staging" - this means we tag with `beta`, allowing
65
+ # a developer to install this version with `yarn add code-server@beta`
66
+ # "production" - this means we tag with `latest` (default), allowing
67
+ # a developer to install this version with `yarn add code-server@latest`
68
+ if ! is_env_var_set " NPM_ENVIRONMENT" ; then
69
+ echo " NPM_ENVIRONMENT is not set. Determining in script based on GITHUB environment variables."
70
+
71
+ if [[ " $GITHUB_EVENT_NAME " == ' push' && " $GITHUB_REF " == ' refs/heads/main' ]]; then
72
+ NPM_ENVIRONMENT=" staging"
73
+ else
74
+ NPM_ENVIRONMENT=" development"
75
+ fi
76
+
77
+ echo " Using npm environment: $NPM_ENVIRONMENT "
78
+ fi
79
+
67
80
# NOTE@jsjoeio - this script assumes we have the artifact downloaded on disk
68
81
# That happens in CI as a step before we run this.
69
82
# https://github.com/actions/upload-artifact/issues/38
0 commit comments