-
-
Save bmutinda/66c64af0a172c9698d57e5cbfa7db994 to your computer and use it in GitHub Desktop.
This is a git hook for git-flow that I use for android studio that auto-bumps the project version and version code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Bumps the version number to relevant files at the end of any release and hotfix start | |
# | |
# Positional arguments: | |
# $1 The version (including the version prefix) | |
# $2 The origin remote | |
# $3 The full branch name (including the release prefix) | |
# $4 The base from which this release is started | |
# | |
# The following variables are available as they are exported by git-flow: | |
# | |
# MASTER_BRANCH - The branch defined as Master | |
# DEVELOP_BRANCH - The branch defined as Develop | |
VERSION=$1 | |
# Remove v prefix (if present) | |
VERSION=${VERSION#"v"} | |
# Generate clean build number | |
VERSION_CODE="$(cat gradle.properties | grep "^VERSION_CODE=.*$" | sed -E 's/^VERSION_CODE=(.*)/\1/')" | |
VERSION_CODE=$(expr $VERSION_CODE + 1) | |
ROOTDIR=$(git rev-parse --show-toplevel) | |
# Bump django version | |
sed -i.bak 's/^VERSION_NAME=.*/VERSION_NAME='''$VERSION'''/' $ROOTDIR/gradle.properties | |
rm gradle.properties.bak | |
# Bump django version | |
sed -i.bak 's/^VERSION_CODE=.*/VERSION_CODE='''$VERSION_CODE'''/' $ROOTDIR/gradle.properties | |
rm gradle.properties.bak | |
# Commit changes | |
git commit -a -m "Version bump $VERSION" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment