set versionCode for nightly builds only in gitlab-ci
Having dynamic build config variables breaks instant APK updates: https://developer.android.com/studio/build/optimize-your-build#use_static_build_properties
This commit is contained in:
parent
361281aa3b
commit
ab87755b20
@ -96,6 +96,9 @@ deploy_nightly:
|
|||||||
- echo "<item>${CI_PROJECT_PATH}-nightly</item>" >> app/src/main/res/values/default_repos.xml
|
- echo "<item>${CI_PROJECT_PATH}-nightly</item>" >> app/src/main/res/values/default_repos.xml
|
||||||
- echo "<item>${CI_PROJECT_URL}-nightly/raw/master/fdroid/repo</item>" >> app/src/main/res/values/default_repos.xml
|
- echo "<item>${CI_PROJECT_URL}-nightly/raw/master/fdroid/repo</item>" >> app/src/main/res/values/default_repos.xml
|
||||||
- cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
|
- cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
|
||||||
|
- export DB=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java`
|
||||||
|
- export versionCode=`printf '%d%05d' $DB $(date '+%s'| cut -b4-8)`
|
||||||
|
- sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $versionCode," app/build.gradle
|
||||||
# build the APKs!
|
# build the APKs!
|
||||||
- ./gradlew assembleDebug
|
- ./gradlew assembleDebug
|
||||||
- fdroid nightly -v
|
- fdroid nightly -v
|
||||||
|
@ -59,32 +59,7 @@ android {
|
|||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
resValue "string", "applicationId", defaultConfig.applicationId + applicationIdSuffix
|
resValue "string", "applicationId", defaultConfig.applicationId + applicationIdSuffix
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
}
|
println 'buildTypes.debug defaultConfig.versionCode ' + defaultConfig.versionCode
|
||||||
}
|
|
||||||
|
|
||||||
/* set the debug versionCode based on DB verson and how many commits in the repo */
|
|
||||||
applicationVariants.all { variant ->
|
|
||||||
if (variant.buildType.isDebuggable()) {
|
|
||||||
// default to a timestamp, in case anything fails later
|
|
||||||
variant.mergedFlavor.versionCode = new Date().getTime() / 1000
|
|
||||||
try {
|
|
||||||
def stdout = new ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD'
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
def commitCount = Integer.parseInt(stdout.toString().trim())
|
|
||||||
stdout = new ByteArrayOutputStream()
|
|
||||||
exec {
|
|
||||||
commandLine 'sed', '-n', 's,.*DB_VERSION *= *\\([0-9][0-9]*\\).*,\\1,p', 'src/main/java/org/fdroid/fdroid/data/DBHelper.java'
|
|
||||||
standardOutput = stdout
|
|
||||||
}
|
|
||||||
def dbVersion = Integer.parseInt(stdout.toString().trim())
|
|
||||||
println 'Setting debug versionCode: ' + sprintf("%d%05d", [dbVersion, commitCount])
|
|
||||||
variant.mergedFlavor.versionCode = Integer.parseInt(sprintf("%d%05d", [dbVersion, commitCount]))
|
|
||||||
}
|
|
||||||
catch (ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user