Skip to content
Snippets Groups Projects
Commit 798b1895 authored by Lennart Goedhart's avatar Lennart Goedhart
Browse files

Set app versionName based on GitHub tags.

parent 9750e319
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ repositories { ...@@ -26,7 +26,7 @@ repositories {
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'realm-android' apply plugin: 'realm-android'
def gitVersion() { def generateVersionCode() {
// current dir is <your proj>/app, so it's likely that all your git repo files are in the dir // current dir is <your proj>/app, so it's likely that all your git repo files are in the dir
// above. // above.
ext.repo = Grgit.open() ext.repo = Grgit.open()
...@@ -34,19 +34,16 @@ def gitVersion() { ...@@ -34,19 +34,16 @@ def gitVersion() {
// should result in the same value as running // should result in the same value as running
// git tag -l | wc -l or git tag -l | grep -c ".*" - // git tag -l | wc -l or git tag -l | grep -c ".*" -
def numOfTags = ext.repo.tag.list().size() def numOfTags = ext.repo.tag.list().size()
logger.warn("Generated Version Code: " + numOfTags)
return numOfTags return numOfTags
} }
def gitCommitId() { def generateVersionName() {
ext.repo = Grgit.open() ext.repo = Grgit.open()
return ext.repo.log().first().id.substring(0, 7) //+ " " + ext.repo.branch.current.name def tag = ext.repo.describe().replaceFirst("^v", "")
} logger.warn("Generated Version Name: " + tag)
return tag
def gitBranch() {
ext.repo = Grgit.open()
return ext.repo.branch.current.name
} }
def getBugfenderApiKey() { def getBugfenderApiKey() {
...@@ -74,8 +71,8 @@ android { ...@@ -74,8 +71,8 @@ android {
applicationId "info.nightscout.android" applicationId "info.nightscout.android"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 25 targetSdkVersion 25
versionName project.properties['version'] + "/" + gitCommitId() // + " (" + gitBranch()+")" versionName generateVersionName()
versionCode gitVersion() versionCode generateVersionCode()
buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey() buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment