diff --git a/scripts/publish.sh b/scripts/publish.sh old mode 100644 new mode 100755 index a7574a15a..eb573e1c7 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -88,13 +88,13 @@ npm run build:release echo "Ran publish build." echo "Making a $VERSION version..." -# TODO: Remove the following command. -# npm version command had previously failed claiming unclean git repo, and we don't know why. -echo "DEBUG: Running git status to show dirty files..." -git status -npm version $VERSION +if [[ $PRE_RELEASE != "" ]]; then + npm version pre$VERSION --preid=rc +else + npm version $VERSION +fi NEW_VERSION=$(jq -r ".version" package.json) -echo "Made a $VERSION version." +echo "Made a $NEW_VERSION version." echo "Making the release notes..." RELEASE_NOTES_FILE=$(mktemp) @@ -105,14 +105,19 @@ cat CHANGELOG.md >> "${RELEASE_NOTES_FILE}" echo "Made the release notes." echo "Publishing to npm..." -if [[ $DRY_RUN == "" ]]; then - npm publish -else +if [[ $DRY_RUN != "" ]]; then echo "DRY RUN: running publish with --dry-run" npm publish --dry-run +else + npm publish fi echo "Published to npm." +if [[ $PRE_RELEASE != "" ]]; then + echo "Published a pre-release version. Skipping post-release actions." + exit +fi + if [[ $DRY_RUN != "" ]]; then echo "All other commands are mutations, and we are doing a dry run." echo "Terminating." diff --git a/scripts/publish/cloudbuild.yaml b/scripts/publish/cloudbuild.yaml index 96b811597..110689cf6 100644 --- a/scripts/publish/cloudbuild.yaml +++ b/scripts/publish/cloudbuild.yaml @@ -99,6 +99,7 @@ steps: - "REPOSITORY_ORG=${_REPOSITORY_ORG}" - "REPOSITORY_NAME=${_REPOSITORY_NAME}" - "DRY_RUN=${_DRY_RUN}" + - "PRE_RELEASE=${_PRE_RELEASE}" options: volumes: @@ -107,6 +108,7 @@ options: substitutions: _VERSION: "" + _PRE_RELEASE: "" _DRY_RUN: "" _KEY_RING: "npm-publish-keyring" _KEY_NAME: "publish"