mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-06 00:45:32 +00:00
When displaying the Info page of alpha builds from the Play Store, we noticed the version string displayed the wrong environment: `14.0.X-alpha-local` (CI builds should have ended with `-alpha`). It turns out the `VERSION_` shell variables from `build-utils.sh` aren't visible in `version.gradle` (though CI environment variables like `build_counter` are visible). This PR: * Exports the two VERSION strings needed in version.gradle * Updates the Info page to simply display `BuildConfig.VERSION_NAME`
55 lines
No EOL
1.9 KiB
Groovy
55 lines
No EOL
1.9 KiB
Groovy
// version.gradle
|
|
|
|
//
|
|
// This depends on ext.rootPath = path to /android folder in repository
|
|
// It can be a relative path. Gradle does not appear to support relative
|
|
// paths from included scripts.
|
|
//
|
|
|
|
def getVersionCode = { ->
|
|
String env_build_counter = System.getenv("build_counter")
|
|
if(env_build_counter != null) {
|
|
// This has been assigned by TeamCity, so use it if present
|
|
println "Using version code $env_build_counter from environment (TeamCity)"
|
|
return env_build_counter
|
|
}
|
|
|
|
println "Using fixed version code 100"
|
|
return 100
|
|
}
|
|
|
|
def getVersionName = { ->
|
|
String env_version = System.getenv("VERSION_WITH_TAG")
|
|
if (env_version != null) {
|
|
// If building from script, we have build number in VERSION_WITH_TAG
|
|
println "Using build $env_version from VERSION_WITH_TAG"
|
|
return "$env_version"
|
|
} else {
|
|
// Building probably from IDE, so let's use VERSION.md and TIER.md directly
|
|
// This is a close match with VERSION_WITH_TAG, except that 'stable' tier
|
|
// is not normally included with VERSION_WITH_TAG
|
|
String version_md = file("$rootPath/../VERSION.md").text.trim()
|
|
String tier_md = file("$rootPath/../TIER.md").text.trim()
|
|
println "Using build $version_md-$tier_md-local from project VERSION.md/TIER.md"
|
|
return "$version_md-$tier_md-local"
|
|
}
|
|
}
|
|
|
|
def getVersionEnvironment = { ->
|
|
String env_environment = System.getenv("VERSION_ENVIRONMENT")
|
|
if (env_environment != null) {
|
|
// If building from script, we have build number in VERSION_ENVIRONMENT
|
|
println "Using $env_environment from VERSION_ENVIRONMENT"
|
|
return "$env_environment"
|
|
} else {
|
|
// Building probably from IDE, so use "local"
|
|
println "Using local environment"
|
|
return "local"
|
|
}
|
|
}
|
|
|
|
ext {
|
|
VERSION_CODE=getVersionCode()
|
|
VERSION_NAME=getVersionName()
|
|
VERSION_ENVIRONMENT=getVersionEnvironment()
|
|
} |