Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86653fa3 authored by Marten Gajda's avatar Marten Gajda
Browse files

Improve version code calculation, implements #786

Version codes of releases (master builds) are now always higher than version codes of beta builds (feature branches).
This ensures we can always update the production release.
parent 9bf85c80
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@ sudo: false
env:
  - TZ=Europe/Berlin

install:
  - git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
  - git fetch --unshallow --tags

android:
  components:
    - tools
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@ COMPILE_SDK_VERSION=26
BUILD_TOOLS_VERSION=27.0.1
MIN_SDK_VERSION=15
TARGET_SDK_VERSION=26
VERSION_OVERRIDE=0
+5 −4
Original line number Diff line number Diff line
@@ -3,10 +3,10 @@ if (project.hasProperty('PLAY_STORE_SERVICE_ACCOUNT_CREDENTIALS')) {
    apply plugin: 'com.github.triplet.play'
}
// commit number is only relevant to the application project
def gitCommitNo = { ->
def gitCommitNo = { ref ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-list', '--count', 'HEAD'
        commandLine 'git', 'rev-list', '--count', ref
        standardOutput = stdout
    }
    return Integer.parseInt(stdout.toString().trim())
@@ -18,7 +18,8 @@ android {
        applicationId "org.dmfs.tasks"
        minSdkVersion MIN_SDK_VERSION.toInteger()
        targetSdkVersion TARGET_SDK_VERSION.toInteger()
        versionCode gitCommitNo() * 10 // spread version code to allow inserting versions if necessary
        // spread version code to allow inserting versions if necessary
        versionCode gitCommitNo('refs/remotes/origin/master') * 99 + gitCommitNo('HEAD') + Integer.parseInt(VERSION_OVERRIDE)
        versionName version
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }