1
1
#! /usr/bin/env bash
2
2
set -euo pipefail
3
3
4
- # TODOs refactor this to determine ENVIRONMENT, NPM_TAG and NPM_VERSION
5
-
6
4
main () {
7
5
cd " $( dirname " $0 " ) /../.."
8
6
source ./ci/lib.sh
@@ -49,19 +47,17 @@ main() {
49
47
exit 1
50
48
fi
51
49
52
- # We need TAG to know what to publish under on npm
53
- # Options are "latest", "beta", or "<pr number >"
54
- # See Environment comments above to know when each is used.
55
- # TODO@jsjoeio - we need to determine this ourselves
56
- if ! is_env_var_set " NPM_TAG" ; then
57
- echo " NPM_TAG is not set. This is needed for tagging the npm release."
50
+ # We use this to grab the PR_NUMBER
51
+ if ! is_env_var_set " GITHUB_REF" ; then
52
+ echo " GITHUB_REF is not set. Are you running this locally? We rely on values provided by GitHub."
58
53
exit 1
59
54
fi
60
55
61
- # TODO@jsjoeio check for these values from GITHUB
62
- # GITHUB_REF GITHUB_SHA
63
-
64
- echo " using tag: $NPM_TAG "
56
+ # We use this when setting NPM_VERSION
57
+ if ! is_env_var_set " GITHUB_SHA" ; then
58
+ echo " GITHUB_SHA is not set. Are you running this locally? We rely on values provided by GitHub."
59
+ exit 1
60
+ fi
65
61
66
62
# This allows us to publish to npm in CI workflows
67
63
if [[ ${CI-} ]]; then
@@ -95,9 +91,6 @@ main() {
95
91
echo " Found environment: $ENVIRONMENT "
96
92
echo " Manually bumping npm version..."
97
93
98
- # TODO@jsjoeio we need to add logic here which determines the NPM_VERSION
99
- # in development, use PR_NUMBER and COMMIT_SHA
100
- # otherwise in staging use NPM_TAG and and COMMIT_SAH
101
94
if [[ " $ENVIRONMENT " == " beta" ]]; then
102
95
NPM_VERSION=" $VERSION -beta-$COMMIT_SHA "
103
96
# This means the npm version will be tagged with "beta"
@@ -114,6 +107,8 @@ main() {
114
107
NPM_TAG=" $PR_NUMBER "
115
108
fi
116
109
110
+ echo " using tag: $NPM_TAG "
111
+
117
112
# We modify the version in the package.json
118
113
# to be the current version + the PR number + commit SHA
119
114
# or we use current version + beta + commit SHA
0 commit comments