File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ android {
77 applicationId " com.github.niqdev.ipcam"
88 minSdkVersion 16
99 targetSdkVersion 28
10- versionCode 12
11- versionName " 1.9.0 "
10+ versionCode getGitCommitCount()
11+ versionName getTag()
1212 }
1313
1414 buildTypes {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ buildscript {
1111
1212allprojects {
1313 group = ' com.github.niqdev'
14- version = ' 1.7.0 '
14+ version = getTag()
1515
1616 repositories {
1717 google()
@@ -22,3 +22,21 @@ allprojects {
2222task clean (type : Delete ) {
2323 delete rootProject. buildDir
2424}
25+
26+ @SuppressWarnings (" unused" )
27+ static def getGitCommitCount () {
28+ def process = " git rev-list HEAD --count" . execute()
29+ return process. text. toInteger()
30+ }
31+
32+ @SuppressWarnings (" unused" )
33+ static def getTag () {
34+ // with local un-commited changes a -DIRTY is added
35+ def processChanges = " git diff-index --name-only HEAD --" . execute()
36+ def dirty = " "
37+ if (! processChanges. text. toString(). trim(). isEmpty())
38+ dirty = " -DIRTY"
39+
40+ def process = " git describe --tags" . execute()
41+ return process. text. toString(). trim() + dirty
42+ }
Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ android {
66 defaultConfig {
77 minSdkVersion 16
88 targetSdkVersion 28
9- versionCode 1
10- versionName project. version
9+ versionName getTag()
1110 }
1211
1312 compileOptions {
You can’t perform that action at this time.
0 commit comments