From 5db18889a1a4216325ebf1c8d5823d09dbbaeea9 Mon Sep 17 00:00:00 2001 From: Mario Vitale Date: Tue, 12 Dec 2023 13:37:15 +0100 Subject: [PATCH] CLD-6707 Followup fixes (#7711) * Fix: rename VERSION to VERSION_NUMBER * Fix: allow BUILD_NUMBER to be set from outside the script --- scripts/bump.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/bump.sh b/scripts/bump.sh index 822910280..19c695b04 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -8,7 +8,7 @@ log () { echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"; } : ${PR_REVIEWERS:=mattermost/core-build-engineers} : ${BUMP_BUILD_NUMBER:=} # You can optionally specify the BUILD_NUMBER variable for selecting the next build number # If you don't, then the Fastlane action will pick the next build number automatically -: ${BUMP_VERSION_NUMBER:=} # If enabled, you must populate the VERSION variable as well +: ${BUMP_VERSION_NUMBER:=} # If enabled, you must populate the VERSION_NUMBER variable as well : ${CREATE_PR:=} # Enable CREATE_PR to push the commit to origin, and create a corresponding PR : ${PR_EXTRA_MESSAGE:=} # Optional message to add in the PR description : ${GIT_LOCAL_BRANCH:=chore-bump-${BRANCH_TO_BUILD}-$(date +%s)} @@ -19,10 +19,10 @@ if [ -z "${BUMP_BUILD_NUMBER}" -a -z "${BUMP_VERSION_NUMBER}" ]; then exit 1 fi if [ -n "$BUMP_VERSION_NUMBER" ]; then - : ${VERSION:?Setting this variable is required when BUMP_VERSION_NUMBER is set.} + : ${VERSION_NUMBER:?Setting this variable is required when BUMP_VERSION_NUMBER is set.} VERSION_REGEXP='^[0-9]+\.[0-9]+\.[0-9]+$' - if ! grep -qE $VERSION_REGEXP"" <<<$VERSION; then - log "Error: the VERSION variable value should match regexp '$VERSION_REGEXP'. Aborting." >&2 + if ! grep -qE $VERSION_REGEXP"" <<<$VERSION_NUMBER; then + log "Error: the VERSION_NUMBER variable value should match regexp '$VERSION_REGEXP'. Aborting." >&2 exit 2 fi fi @@ -38,9 +38,11 @@ CURRENT_BRANCH=$(git branch --show-current) trap "git checkout $CURRENT_BRANCH" EXIT if [ -n "$BUMP_BUILD_NUMBER" ]; then - log "Selecting the next largest build number..." - LATEST_BUILD_NUMBER=$(./scripts/get_latest_build_number.sh) - BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1)) + if [ -z "${BUILD_NUMBER:-}" ]; then + log "Selecting the next largest build number..." + LATEST_BUILD_NUMBER=$(./scripts/get_latest_build_number.sh) + BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1)) + fi log "Build number to use for the beta build: $BUILD_NUMBER" fi @@ -60,7 +62,7 @@ export BUILD_NUMBER=${BUILD_NUMBER} " || :) $([ -n "$BUMP_VERSION_NUMBER" ] && echo "\ export INCREMENT_VERSION_NUMBER=true -export VERSION=${VERSION} +export VERSION_NUMBER=${VERSION_NUMBER} " || :) EOF @@ -89,14 +91,14 @@ if [ -n "${CREATE_PR}" ]; then --head "${GIT_LOCAL_BRANCH}" \ --reviewer "${PR_REVIEWERS}" \ --title "$PR_TITLE" \ - $([ -z "$BUMP_VERSION_NUMBER" ] || echo -n "--milestone v${VERSION} --label CherryPick/Approved") \ + $([ -z "$BUMP_VERSION_NUMBER" ] || echo -n "--milestone v${VERSION_NUMBER} --label CherryPick/Approved") \ --body-file - <