Skip to content

Commit

Permalink
Automatic version code (#115)
Browse files Browse the repository at this point in the history
Co-authored-by: niqdev <niqdev@users.noreply.github.com>
  • Loading branch information
hannesa2 and niqdev authored Mar 29, 2021
1 parent abf09d5 commit 1b278ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.github.niqdev.ipcam"
minSdkVersion 16
targetSdkVersion 28
versionCode 12
versionName "1.9.0"
versionCode getGitCommitCount()
versionName getTag()
}

buildTypes {
Expand Down
20 changes: 19 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

allprojects {
group = 'com.github.niqdev'
version = '1.7.0'
version = getTag()

repositories {
google()
Expand All @@ -22,3 +22,21 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

@SuppressWarnings("unused")
static def getGitCommitCount() {
def process = "git rev-list HEAD --count".execute()
return process.text.toInteger()
}

@SuppressWarnings("unused")
static def getTag() {
// with local un-commited changes a -DIRTY is added
def processChanges = "git diff-index --name-only HEAD --".execute()
def dirty = ""
if (!processChanges.text.toString().trim().isEmpty())
dirty = "-DIRTY"

def process = "git describe --tags".execute()
return process.text.toString().trim() + dirty
}
3 changes: 1 addition & 2 deletions mjpeg-view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName project.version
versionName getTag()
}

compileOptions {
Expand Down

0 comments on commit 1b278ca

Please sign in to comment.