Created
February 3, 2017 13:40
-
-
Save rrrnld/d9295b6382d2345adafa4a076d0a348c to your computer and use it in GitHub Desktop.
Android build version with git commit hash
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
// merge this with your current build.gradle | |
// generates a version name from currently checked out git commit | |
def getCommitHash = { -> | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'rev-parse', '--short', 'HEAD' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim() | |
} | |
android { | |
// ... | |
defaultConfig { | |
// ... | |
versionName '1-' + getCommitHash() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment