mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
Android: Use automatic build numbers based on Git history
This commit is contained in:
parent
533722456b
commit
7dce9d4b9b
|
@ -7,9 +7,8 @@ android {
|
||||||
applicationId "com.github.stenzek.duckstation"
|
applicationId "com.github.stenzek.duckstation"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode(getBuildVersionCode())
|
||||||
versionName "1.0"
|
versionName "${getVersion()}"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -49,3 +48,32 @@ dependencies {
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adapted from Dolphin.
|
||||||
|
|
||||||
|
def getVersion() {
|
||||||
|
def versionNumber = '0.0-unknown'
|
||||||
|
|
||||||
|
try {
|
||||||
|
versionNumber = 'git describe --tags --exclude latest'.execute([], project.rootDir).text
|
||||||
|
.trim()
|
||||||
|
.replaceAll(/(-0)?-[^-]+$/, "")
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error('Cannot find git, defaulting to dummy version number')
|
||||||
|
}
|
||||||
|
|
||||||
|
return versionNumber
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def getBuildVersionCode() {
|
||||||
|
try {
|
||||||
|
def versionNumber = 'git rev-list --first-parent --count HEAD'.execute([], project.rootDir).text
|
||||||
|
.trim()
|
||||||
|
return Integer.valueOf(versionNumber);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error('Cannot find git, defaulting to dummy version number')
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue