From b71eef75a328b954cb6deee4fa69cd01c012279e Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Thu, 13 Oct 2022 15:30:17 -0700 Subject: [PATCH 1/3] Modify release script to support releasing pre-release versions. --- scripts/publish.sh | 21 ++++++++++++++------- scripts/publish/cloudbuild.yaml | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) mode change 100644 => 100755 scripts/publish.sh diff --git a/scripts/publish.sh b/scripts/publish.sh old mode 100644 new mode 100755 index a7574a15a..94693a9a8 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -2,12 +2,14 @@ set -e printusage() { - echo "publish.sh " + echo "publish.sh [--prerelease]" echo "REPOSITORY_ORG and REPOSITORY_NAME should be set in the environment." echo "e.g. REPOSITORY_ORG=user, REPOSITORY_NAME=repo" echo "" echo "Arguments:" echo " version: 'patch', 'minor', or 'major'." + echo "Flags:" + echo " --prerelease: Set to publish a prerelease version (e.g. 4.0.1-rc.0)" } VERSION=$1 @@ -19,6 +21,11 @@ elif [[ ! ($VERSION == "patch" || $VERSION == "minor" || $VERSION == "major") ]] exit 1 fi +PRERELEASE=false +if [[ $2 == "--prerelease" || $2 == "-p" ]]; then + PRERELEASE=true +fi + if [[ $REPOSITORY_ORG == "" ]]; then printusage exit 1 @@ -88,13 +95,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 [[ "$PRERELEASE" = true ]]; 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) diff --git a/scripts/publish/cloudbuild.yaml b/scripts/publish/cloudbuild.yaml index 96b811597..deeee45cf 100644 --- a/scripts/publish/cloudbuild.yaml +++ b/scripts/publish/cloudbuild.yaml @@ -94,7 +94,7 @@ steps: # Publish the package. - name: "gcr.io/$PROJECT_ID/package-builder" dir: "${_REPOSITORY_NAME}" - args: ["bash", "./scripts/publish.sh", "${_VERSION}"] + args: ["bash", "./scripts/publish.sh", "${_VERSION}", "${_PRERELEASE}"] env: - "REPOSITORY_ORG=${_REPOSITORY_ORG}" - "REPOSITORY_NAME=${_REPOSITORY_NAME}" @@ -107,6 +107,7 @@ options: substitutions: _VERSION: "" + _PRERELEASE: "" _DRY_RUN: "" _KEY_RING: "npm-publish-keyring" _KEY_NAME: "publish" From df80c25a6530ab0869e6313f4a5222a85b5c9829 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Thu, 13 Oct 2022 15:37:37 -0700 Subject: [PATCH 2/3] Modify release script to support releasing pre-release version of Firebase Functions SDK. --- scripts/publish.sh | 20 +++++++++----------- scripts/publish/cloudbuild.yaml | 5 +++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 94693a9a8..93aa2e8a1 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -2,14 +2,12 @@ set -e printusage() { - echo "publish.sh [--prerelease]" + echo "publish.sh " echo "REPOSITORY_ORG and REPOSITORY_NAME should be set in the environment." echo "e.g. REPOSITORY_ORG=user, REPOSITORY_NAME=repo" echo "" echo "Arguments:" echo " version: 'patch', 'minor', or 'major'." - echo "Flags:" - echo " --prerelease: Set to publish a prerelease version (e.g. 4.0.1-rc.0)" } VERSION=$1 @@ -21,11 +19,6 @@ elif [[ ! ($VERSION == "patch" || $VERSION == "minor" || $VERSION == "major") ]] exit 1 fi -PRERELEASE=false -if [[ $2 == "--prerelease" || $2 == "-p" ]]; then - PRERELEASE=true -fi - if [[ $REPOSITORY_ORG == "" ]]; then printusage exit 1 @@ -95,10 +88,10 @@ npm run build:release echo "Ran publish build." echo "Making a $VERSION version..." -if [[ "$PRERELEASE" = true ]]; then - npm version pre$VERSION --preid=rc -else +if [[ $PRE_RELEASE == "" ]]; then npm version $VERSION +else + npm version pre$VERSION --preid=rc fi NEW_VERSION=$(jq -r ".version" package.json) echo "Made a $NEW_VERSION version." @@ -120,6 +113,11 @@ else 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 deeee45cf..110689cf6 100644 --- a/scripts/publish/cloudbuild.yaml +++ b/scripts/publish/cloudbuild.yaml @@ -94,11 +94,12 @@ steps: # Publish the package. - name: "gcr.io/$PROJECT_ID/package-builder" dir: "${_REPOSITORY_NAME}" - args: ["bash", "./scripts/publish.sh", "${_VERSION}", "${_PRERELEASE}"] + args: ["bash", "./scripts/publish.sh", "${_VERSION}"] env: - "REPOSITORY_ORG=${_REPOSITORY_ORG}" - "REPOSITORY_NAME=${_REPOSITORY_NAME}" - "DRY_RUN=${_DRY_RUN}" + - "PRE_RELEASE=${_PRE_RELEASE}" options: volumes: @@ -107,7 +108,7 @@ options: substitutions: _VERSION: "" - _PRERELEASE: "" + _PRE_RELEASE: "" _DRY_RUN: "" _KEY_RING: "npm-publish-keyring" _KEY_NAME: "publish" From c10da3a8f7853059363b4172514493069876b5c0 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Fri, 14 Oct 2022 08:46:55 -0700 Subject: [PATCH 3/3] Improve consistency of conditionals. --- scripts/publish.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/publish.sh b/scripts/publish.sh index 93aa2e8a1..eb573e1c7 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -88,10 +88,10 @@ npm run build:release echo "Ran publish build." echo "Making a $VERSION version..." -if [[ $PRE_RELEASE == "" ]]; then - npm version $VERSION -else +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 $NEW_VERSION version." @@ -105,11 +105,11 @@ 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."