Skip to content

Instantly share code, notes, and snippets.

@mochadwi
Last active April 5, 2020 04:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mochadwi/5ea5d14ea0f906dc0a376e362cc6ff5f to your computer and use it in GitHub Desktop.
Save mochadwi/5ea5d14ea0f906dc0a376e362cc6ff5f to your computer and use it in GitHub Desktop.
Release script to automate versioning and git tagging

Pre-requisites

  • Add Triple-T dependencies
  • Setup the service account on GCP & link to Play Store (explained in the README.md of Triple-T)
  • Create custom gradle task (to bump version) or see here
  • Use git-flow as branching model

Notes

  • Change $VERSION_NAME, $VERSION_CODE, $BUILD_GRADLE_FILE & $MODULE_NAME accordingly to your needs
  • VERSION_NAME="vX.Y.Z"

How to

  • Run this: curl -s -L https://git.io/JedBV | bash
#!/bin/sh
# global env
MODULE_NAME="legacy"
BUILD_GRADLE_FILE="build.gradle.kts"
TRACK=$1
USER_FRACTION=$2
if [ "$#" -lt 1 ]; then
echo "Illegal number of parameters - required"
echo "1st argument for --track e.g: internal, alpha, beta or production"
echo "2nd argument for --user-fraction e.g: 0.1 = 10%; 0.25 = 25%; 1 = 100%"
exit
fi
export VERSION_NAME=`egrep '^[[:blank:]]+versionName[[:blank:]]' ${MODULE_NAME}/${BUILD_GRADLE_FILE} | awk '{print $3}' | sed s/\"//g`
export VERSION_CODE=`egrep '^[[:blank:]]+versionCode[[:blank:]]' ${MODULE_NAME}/${BUILD_GRADLE_FILE} | awk '{print $3}' | sed s/\"//g`
# 01. bumper versionCode & versionName with gradle task
# 02. check for the information (receive user input)
# git ls/info || git status
# 03a. (BETA RELEASE) checkout & annotate with git tag
git checkout -b release/${VERSION_NAME}
git tag -a $VERSION_NAME -m "beta release to play store for ${VERSION_NAME} (${VERSION_CODE})"
# 03b. (HOTFIX RELEASE) checkout & annotate with git tag
git checkout -b hotfix/${VERSION_NAME}
git tag -a $VERSION_NAME -m "hotfix release to play store for ${VERSION_NAME} (${VERSION_CODE})"
# 04. git add modified gradle file + git push new branch & tag
git add ${MODULE_NAME}/${BUILD_GRADLE_FILE}
# 04a. commit+push for beta release
git commit -m "beta release to play store for ${VERSION_NAME} (${VERSION_CODE})"
git push -u origin release/${VERSION_NAME} && git push origin ${VERSION_NAME}
# 04b. commit+push for hotfix release
git commit -m "hotfix release to play store for ${VERSION_NAME} (${VERSION_CODE})"
git push -u origin hotfix/${VERSION_NAME} && git push origin ${VERSION_NAME}
# 05. auto-publish the AAB
# ./gradlew publishProdReleaseBundle --track=$TRACK --user-fraction=$USER_FRACTION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment