diff --git a/app/build.gradle b/app/build.gradle index 5dffd2304..81c8ef64b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -237,6 +237,32 @@ android { } } + /* 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) { + } + } + } + testOptions { unitTests { // prevent tests from dying on android.util.Log calls diff --git a/config/nightly-repo/deploy b/config/nightly-repo/deploy index b6520fcfd..71778fb37 100755 --- a/config/nightly-repo/deploy +++ b/config/nightly-repo/deploy @@ -9,10 +9,6 @@ apt-get update apt-get install -y --no-install-recommends -t stretch-backports \ fdroidserver openssh-client rsync python3-qrcode -db=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java` -count=`git rev-list --first-parent --count HEAD` -sed -i "s,versionCode *[0-9][0-9]*.*,versionCode `printf '%d%05d' $db $count`," app/build.gradle - repo_git_base=${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}-nightly repo_base=https://gitlab.com/${repo_git_base} repo_url=${repo_base}/raw/master/fdroid/repo