Skip to content

Commit 7ed2dbb

Browse files
authored
Update release script to support making release candidates (#1261)
Adding a new flag to allow us to create a release candidates with versions like `4.0.0-rc.0`. Instructions added on go/publish-via-cloud-build.
1 parent a8b3cc4 commit 7ed2dbb

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

scripts/publish.sh

100644100755
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ npm run build:release
8888
echo "Ran publish build."
8989

9090
echo "Making a $VERSION version..."
91-
# TODO: Remove the following command.
92-
# npm version command had previously failed claiming unclean git repo, and we don't know why.
93-
echo "DEBUG: Running git status to show dirty files..."
94-
git status
95-
npm version $VERSION
91+
if [[ $PRE_RELEASE != "" ]]; then
92+
npm version pre$VERSION --preid=rc
93+
else
94+
npm version $VERSION
95+
fi
9696
NEW_VERSION=$(jq -r ".version" package.json)
97-
echo "Made a $VERSION version."
97+
echo "Made a $NEW_VERSION version."
9898

9999
echo "Making the release notes..."
100100
RELEASE_NOTES_FILE=$(mktemp)
@@ -105,14 +105,19 @@ cat CHANGELOG.md >> "${RELEASE_NOTES_FILE}"
105105
echo "Made the release notes."
106106

107107
echo "Publishing to npm..."
108-
if [[ $DRY_RUN == "" ]]; then
109-
npm publish
110-
else
108+
if [[ $DRY_RUN != "" ]]; then
111109
echo "DRY RUN: running publish with --dry-run"
112110
npm publish --dry-run
111+
else
112+
npm publish
113113
fi
114114
echo "Published to npm."
115115

116+
if [[ $PRE_RELEASE != "" ]]; then
117+
echo "Published a pre-release version. Skipping post-release actions."
118+
exit
119+
fi
120+
116121
if [[ $DRY_RUN != "" ]]; then
117122
echo "All other commands are mutations, and we are doing a dry run."
118123
echo "Terminating."

scripts/publish/cloudbuild.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ steps:
9999
- "REPOSITORY_ORG=${_REPOSITORY_ORG}"
100100
- "REPOSITORY_NAME=${_REPOSITORY_NAME}"
101101
- "DRY_RUN=${_DRY_RUN}"
102+
- "PRE_RELEASE=${_PRE_RELEASE}"
102103

103104
options:
104105
volumes:
@@ -107,6 +108,7 @@ options:
107108

108109
substitutions:
109110
_VERSION: ""
111+
_PRE_RELEASE: ""
110112
_DRY_RUN: ""
111113
_KEY_RING: "npm-publish-keyring"
112114
_KEY_NAME: "publish"

0 commit comments

Comments
 (0)