Skip to content

Commit

Permalink
Checkout branch within version bump script
Browse files Browse the repository at this point in the history
  • Loading branch information
mvitale1989 committed Nov 24, 2023
1 parent ef46a37 commit f49bea9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/bump-build-number.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0
ref: main

- name: bump-build-number/setup-ruby
uses: ruby/setup-ruby@9669f3ee51dc3f4eda8447ab696b3ab19a90d14b # v1.144.0
Expand Down
25 changes: 19 additions & 6 deletions scripts/bump_build_number.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
#!/bin/bash
set -eu -o pipefail
cd "$(dirname "$0")"/..

log () {
echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"
}
log () { echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"; }

cd "$(dirname "$0")"/..
log "Asserting that the workdir is clean"
if ! git diff --quiet; then
log "Error, workdir is not clean: aborting" >&2
exit 1
fi

log "Saving currently checked out branch"
CURRENT_BRANCH=$(git branch --show-current)
trap "git checkout $CURRENT_BRANCH" EXIT

: ${BRANCH_TO_BUILD:=main}
: ${GIT_LOCAL_BRANCH:=bump-build}
LATEST_BUILD_NUMBER=$(./scripts/get_latest_build_number.sh)
BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1))
log "Build number to use for the beta build: $BUILD_NUMBER"

log "Checking out branch to build: $BRANCH_TO_BUILD"
git checkout $BRANCH_TO_BUILD

log "Generating env file required by Fastlane..."
tee .env <<EOF
export INCREMENT_BUILD_NUMBER=true
export BUILD_NUMBER=${BUILD_NUMBER}
export COMMIT_CHANGES_TO_GIT=true
export BRANCH_TO_BUILD=main
export GIT_LOCAL_BRANCH=bump-build
export BRANCH_TO_BUILD=${BRANCH_TO_BUILD}
export GIT_LOCAL_BRANCH=${GIT_LOCAL_BRANCH}
EOF

log "Running the fastlane branch generation script"
Expand Down

0 comments on commit f49bea9

Please sign in to comment.