From 1e6cde67905529c8052eca4bedadc0e7d7711f6b Mon Sep 17 00:00:00 2001 From: vanous Date: Thu, 27 Jan 2022 18:00:22 +0100 Subject: [PATCH] Add nightly release setup --- .woodpecker/can_master_build.yml | 6 +-- app/build.gradle | 65 +++++++++++++++++++++++++ app/src/main/AndroidManifest.xml | 2 +- app/src/nightly/res/values/strings.xml | 4 ++ app/src/nopebble/res/values/strings.xml | 4 ++ 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 app/src/nightly/res/values/strings.xml create mode 100644 app/src/nopebble/res/values/strings.xml diff --git a/.woodpecker/can_master_build.yml b/.woodpecker/can_master_build.yml index 1c6846dfd..c5136d7bb 100644 --- a/.woodpecker/can_master_build.yml +++ b/.woodpecker/can_master_build.yml @@ -5,9 +5,9 @@ pipeline: - pwd #bump - ./gradlew assembleDebug --stacktrace + when: + repo: Freeyourgadget/Gadgetbridge + branch: master #this doesn't work yet: #https://github.com/woodpecker-ci/woodpecker/issues/687 -#when: - #repo: Freeyourgadget/Gadgetbridge - #branch: master diff --git a/app/build.gradle b/app/build.gradle index 88875f6a6..c20245f8c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,18 @@ tasks.withType(Test) { systemProperty "logback.configurationFile", System.getProperty("user.dir", null) + "/app/src/main/assets/logback.xml" systemProperty "GB_LOGFILES_DIR", Files.createTempDirectory("gblog").toString() } +def getVersionCode = { -> + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-list', 'HEAD', '--count' + standardOutput = stdout + } + return Integer.valueOf(stdout.toString().trim()) + } catch (ignored) { + return null + } +} def getGitHashShort = { -> try { @@ -49,12 +61,65 @@ android { vectorDrawables.useSupportLibrary = true multiDexEnabled true buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\"" + resValue "string", "pebble_content_provider", "com.getpebble.android.provider" + } + signingConfigs { + nightly { + if (System.getProperty("nightly_store_file") != null) { + storeFile file(System.getProperty("nightly_store_file")) + storePassword System.getProperty("nightly_store_password") + keyAlias System.getProperty("nightly_key_alias") + keyPassword System.getProperty("nightly_key_password") + } + } } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + resValue "string", "pebble_content_provider", "com.getpebble.android.provider" } + + nightly { + applicationIdSuffix ".nightly" + versionNameSuffix "-${getGitHashShort}" + minifyEnabled true + if (System.getProperty("nightly_store_file") != null) { + signingConfig signingConfigs.nightly + } else { + signingConfig signingConfigs.debug + } + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + resValue "string", "pebble_content_provider", "com.getpebble.android.provider" + debuggable true + } + nopebble { + applicationIdSuffix ".nightly_nopebble" + versionNameSuffix "-${getGitHashShort}" + minifyEnabled true + if (System.getProperty("nightly_store_file") != null) { + signingConfig signingConfigs.nightly + } else { + signingConfig signingConfigs.debug + } + proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + resValue "string", "pebble_content_provider", "com.getpebble.android.nopebble.provider" + debuggable true + } + + applicationVariants.all { variant -> + variant.resValue "string", "applicationId", variant.applicationId + + if (variant.buildType.name == 'nightly' || variant.buildType.name == 'nopebble') { + variant.outputs.all { + setVersionCodeOverride(getVersionCode()) + //setVersionNameOverride(getGitHashShort()) + setVersionNameOverride(variant.versionName) + outputFileName = "${applicationId}_${variant.versionName}.apk" + } + } + } + } lintOptions { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 45e81503c..fac9decb4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -527,7 +527,7 @@ + + Gadgetbridge (Nightly) + diff --git a/app/src/nopebble/res/values/strings.xml b/app/src/nopebble/res/values/strings.xml new file mode 100644 index 000000000..090f10a24 --- /dev/null +++ b/app/src/nopebble/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Gadgetbridge (Nightly, No Pebble provider) +