CLD-7006 Fix version bump script pt2 (#7775)
* Fix version bump script pt2 * Make shellcheck happy
This commit is contained in:
parent
efaa519c30
commit
45eadc07da
1 changed files with 18 additions and 15 deletions
|
|
@ -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 <<EOF
|
||||
|
|
@ -81,18 +82,20 @@ fi
|
|||
|
||||
if [ -n "${CREATE_PR}" ]; then
|
||||
log "Pushing branch ${GIT_LOCAL_BRANCH}, and creating a corresponding PR to ${BRANCH_TO_BUILD}"
|
||||
git push origin ${GIT_LOCAL_BRANCH}
|
||||
git push origin "${GIT_LOCAL_BRANCH}"
|
||||
|
||||
log "Creating PR"
|
||||
PR_TITLE="Bump app ${BUMP_BUILD_NUMBER:+build}${BUMP_VERSION_NUMBER:+${BUMP_BUILD_NUMBER:+ and }version} number"
|
||||
# We won't specify the milestone when opening the PR if either we're not bumping the version number, or if the milestone is not found
|
||||
MILESTONE_FOUND=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/mattermost/mattermost-mobile/milestones | jq -r ".[] | .title | select(. == \"v${VERSION_NUMBER:-}\")")
|
||||
#shellcheck disable=SC2046
|
||||
gh pr create \
|
||||
--repo mattermost/mattermost-mobile \
|
||||
--base "${BRANCH_TO_BUILD}" \
|
||||
--head "${GIT_LOCAL_BRANCH}" \
|
||||
--reviewer "${PR_REVIEWERS}" \
|
||||
--title "$PR_TITLE" \
|
||||
$([ -z "$BUMP_VERSION_NUMBER" -o -z "${MILESTONE_FOUND}" ] || echo -n "--milestone v${VERSION_NUMBER} --label CherryPick/Approved" # Do not specify the milestone if not bumping the version number, or if the milestone is not found) \
|
||||
$([ -z "$BUMP_VERSION_NUMBER" -o -z "${MILESTONE_FOUND}" ] || echo -n "--milestone v${VERSION_NUMBER} --label CherryPick/Approved") \
|
||||
--body-file - <<EOF
|
||||
#### Summary
|
||||
$([ -z "$BUMP_BUILD_NUMBER" ] || echo "\
|
||||
|
|
|
|||
Loading…
Reference in a new issue