Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions owncloudApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ android {
minSdkVersion 19
targetSdkVersion 28

versionCode = 21300100
versionName = "2.13.1"
versionCode = getGitCommitCount()
versionName = getTag()

buildConfigField "String", gitRemote, "\"" + getGitOriginRemote() + "\""
buildConfigField "String", commitSHA1, "\"" + getLatestGitHash() + "\""
Expand Down Expand Up @@ -195,13 +195,8 @@ def setOutputFileName(variant, appName, callerProject) {
}

def versionName = "$variant.mergedFlavor.versionName"
if (variant.mergedFlavor.manifestPlaceholders.versionName != null) {
versionName = "$variant.mergedFlavor.manifestPlaceholders.versionName"
}
if (variant.buildType.manifestPlaceholders.versionName != null) {
versionName = "$variant.buildType.manifestPlaceholders.versionName"
}
newName += "_$versionName"
def versionCode = "$variant.mergedFlavor.versionCode".toInteger()
newName += "_$versionName-$versionCode"

def buildNumber = System.env.OC_BUILD_NUMBER
if (buildNumber) {
Expand All @@ -217,6 +212,16 @@ def setOutputFileName(variant, appName, callerProject) {
}
}

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

static def getTag() {
def process = "git describe --abbrev=0".execute()
return process.text.toString().trim()
}

static def getLatestGitHash() {
def process = "git rev-parse --short HEAD".execute()
return process.text.toString().trim()
Expand Down