From 45eadc07da9464174edbbe7602cf21c5d8c28522 Mon Sep 17 00:00:00 2001 From: Mario Vitale Date: Mon, 22 Jan 2024 14:59:23 +0100 Subject: [PATCH] CLD-7006 Fix version bump script pt2 (#7775) * Fix version bump script pt2 * Make shellcheck happy --- scripts/bump.sh | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/bump.sh b/scripts/bump.sh index 85e8e027a..3fae11701 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -1,17 +1,18 @@ #!/bin/bash +#shellcheck disable=SC2166,SC2064,SC2015 set -eu -o pipefail cd "$(dirname "$0")"/.. log () { echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"; } -: ${BRANCH_TO_BUILD:=main} -: ${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_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)} +: "${BRANCH_TO_BUILD:=main}" +: "${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_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)}" log "Checking that the configuration is sane" if [ -z "${BUMP_BUILD_NUMBER}" -a -z "${BUMP_VERSION_NUMBER}" ]; then @@ -19,9 +20,9 @@ if [ -z "${BUMP_BUILD_NUMBER}" -a -z "${BUMP_VERSION_NUMBER}" ]; then exit 1 fi if [ -n "$BUMP_VERSION_NUMBER" ]; then - : ${VERSION_NUMBER:?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_NUMBER; then + 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 @@ -41,15 +42,15 @@ if [ -n "$BUMP_BUILD_NUMBER" ]; then 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)) + BUILD_NUMBER=$((LATEST_BUILD_NUMBER + 1)) fi log "Build number to use for the beta build: $BUILD_NUMBER" fi log "Creating branch '${GIT_LOCAL_BRANCH}' based on branch '$BRANCH_TO_BUILD'" -git checkout $BRANCH_TO_BUILD +git checkout "$BRANCH_TO_BUILD" git pull -git checkout -b $GIT_LOCAL_BRANCH +git checkout -b "$GIT_LOCAL_BRANCH" log "Generating env file required by Fastlane..." tee .env <