Skip to content

Commit 6ab1213

Browse files
committed
wip: almost done
1 parent d2e6ab2 commit 6ab1213

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

ci/steps/publish-npm.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ main() {
5858
exit 1
5959
fi
6060

61+
#TODO@jsjoeio check for these values from GITHUB
62+
# GITHUB_REF GITHUB_SHA
63+
6164
echo "using tag: $NPM_TAG"
6265

6366
# This allows us to publish to npm in CI workflows
@@ -83,20 +86,39 @@ main() {
8386
# in the package.json and we commit it as part of the release PR.
8487
if [[ "$ENVIRONMENT" == "production" ]]; then
8588
NPM_VERSION="$VERSION"
89+
# This means the npm version will be published as "stable"
90+
# and installed when a user runs `yarn install code-server`
91+
NPM_TAG="latest"
8692
else
93+
COMMIT_SHA="$GITHUB_SHA"
8794
echo "Not a production environment"
8895
echo "Found environment: $ENVIRONMENT"
8996
echo "Manually bumping npm version..."
9097

91-
if ! is_env_var_set "PR_NUMBER_AND_COMMIT_SHA"; then
92-
echo "PR_NUMBER_AND_COMMIT_SHA is not set. This is needed for setting the npm version in non-production environments."
93-
exit 1
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+
if [[ "$ENVIRONMENT" == "beta" ]]; then
102+
NPM_VERSION="$VERSION-beta-$COMMIT_SHA"
103+
# This means the npm version will be tagged with "beta"
104+
# and installed when a user runs `yarn install code-server@beta`
105+
NPM_TAG="beta"
106+
fi
107+
108+
if [[ "$ENVIRONMENT" == "development" ]]; then
109+
# Source: https://github.com/actions/checkout/issues/58#issuecomment-614041550
110+
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
111+
NPM_VERSION="$VERSION-$PR_NUMBER-$COMMIT_SHA"
112+
# This means the npm version will be tagged with "<pr number>"
113+
# and installed when a user runs `yarn install code-server@<pr number>`
114+
NPM_TAG="$PR_NUMBER"
94115
fi
95116

96117
# We modify the version in the package.json
97118
# to be the current version + the PR number + commit SHA
119+
# or we use current version + beta + commit SHA
98120
# Example: "version": "4.0.1-4769-ad7b23cfe6ffd72914e34781ef7721b129a23040"
99-
NPM_VERSION="$VERSION-$PR_NUMBER_AND_COMMIT_SHA"
121+
# Example: "version": "4.0.1-beta-ad7b23cfe6ffd72914e34781ef7721b129a23040"
100122
pushd release
101123
# NOTE:@jsjoeio
102124
# I originally tried to use `yarn version` but ran into issues and abandoned it.

0 commit comments

Comments
 (0)