Skip to content

Commit

Permalink
Add branch push and PR creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvitale1989 committed Nov 25, 2023
1 parent af8afa0 commit f8808c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
30 changes: 26 additions & 4 deletions scripts/bump_build_number.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd "$(dirname "$0")"/..
log () { echo "[$(date +%Y-%m-%dT%H:%M:%S%Z)]" "$@"; }

log "Asserting that the workdir is clean"
if ! git diff --quiet; then
if [ -n "$(git status --porcelain)" ]; then
log "Error, workdir is not clean: aborting" >&2
exit 1
fi
Expand All @@ -15,6 +15,8 @@ CURRENT_BRANCH=$(git branch --show-current)
trap "git checkout $CURRENT_BRANCH" EXIT

: ${BRANCH_TO_BUILD:=main}
: ${PR_REVIEWERS:=mattermost/core-build-engineers}
: ${DRY_RUN:=}
LATEST_BUILD_NUMBER=$(./scripts/get_latest_build_number.sh)
BUILD_NUMBER=$(($LATEST_BUILD_NUMBER + 1))
GIT_LOCAL_BRANCH=bump-build-${BRANCH_TO_BUILD}-${BUILD_NUMBER}
Expand All @@ -37,6 +39,26 @@ EOF
log "Running the fastlane build number bumper script"
(. .env && cd fastlane && bundle exec fastlane set_app_build_number)

# TODO push the ${GIT_LOCAL_BRANCH} branch, and create a PR for it
# TODO put the core-build-engineers as PR reviewers
git branch -l -a
if [ -n "${DRY_RUN}" ]; then
log "Pushing branch ${GIT_LOCAL_BRANCH}, and creating a corresponding PR to ${BRANCH_TO_BUILD}"
git push origin ${GIT_LOCAL_BRANCH}

log "Creating PR"
gh pr create \
--repo mattermost/mattermost-mobile \
--base main \
--head "${GIT_LOCAL_BRANCH}" \
--reviewer "${PR_REVIEWERS}"
--title "Bump app build number to $BUILD_NUMBER" \
--body-file - <<EOF
#### Summary
Bump app build number to $BUILD_NUMBER
#### Release Note
```release-note
NONE
```
EOF
else
log "Running in DRY_RUN mode: skipping branch push and PR creation"
fi
2 changes: 1 addition & 1 deletion scripts/get_latest_build_number.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ print_all_remote_refs () {

BUILD_NUMBERS=""
for REMOTE_BRANCH in $(print_all_remote_refs); do
# Purposely swallow errors here, and continue to loop if the file we get the versionCode from is absent
# Intentionally ignore errors here: we don't want invalid brances, e.g. where the required file is removed, to make this script fail
BUILD_NUMBER=$(git cat-file -p ${REMOTE_BRANCH}:android/app/build.gradle | grep -E 'versionCode [0-9]+' | awk '{ print $2; }') || continue
BUILD_NUMBERS="$BUILD_NUMBERS $BUILD_NUMBER"
done
Expand Down

0 comments on commit f8808c0

Please sign in to comment.