Skip to content

Commit 0ef2bf8

Browse files
authored
[test] enable release testapp to playstore MAPSAND-120 (#1441)
* enable release testapp to playstore * update build.gradle to use play-publisher plugin for release * update build.gradle and ci config job to use debug config * trigger ci
1 parent 149e330 commit 0ef2bf8

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

app/build.gradle.kts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,56 @@ plugins {
55
id("io.gitlab.arturbosch.detekt").version(Versions.detekt)
66
}
77

8+
apply {
9+
from("$rootDir/gradle/script-git-version.gradle")
10+
from("$rootDir/gradle/play-publisher.gradle")
11+
}
812
val buildFromSource: String by project
913

1014
android {
1115
compileSdk = AndroidVersions.compileSdkVersion
16+
signingConfigs {
17+
create("release") {
18+
storeFile = rootProject.file("$rootDir/testapp-release.keystore")
19+
storePassword = if (project.hasProperty("APP_KEYSTORE_PASSWORD")) {
20+
project.property("APP_KEYSTORE_PASSWORD") as String
21+
} else {
22+
System.getenv("APP_KEYSTORE_PASSWORD")
23+
}
24+
keyAlias = if (project.hasProperty("APP_KEYSTORE_ALIAS")) {
25+
project.property("APP_KEYSTORE_ALIAS") as String
26+
} else {
27+
System.getenv("APP_KEYSTORE_ALIAS")
28+
}
29+
keyPassword = if (project.hasProperty("APP_KEY_PASSWORD")) {
30+
project.property("APP_KEY_PASSWORD") as String
31+
} else {
32+
System.getenv("APP_KEY_PASSWORD")
33+
}
34+
}
35+
}
1236
defaultConfig {
1337
applicationId = "com.mapbox.maps.testapp"
1438
minSdk = AndroidVersions.minSdkVersion
1539
targetSdk = AndroidVersions.targetSdkVersion
16-
versionCode = 1
17-
versionName = "0.1.0"
40+
versionCode = if (project.hasProperty("gitVersionCode")) project.property("gitVersionCode") as Int else 1
41+
versionName = if (project.hasProperty("gitVersionName")) project.property("gitVersionName") as String else "0.1.0"
1842
multiDexEnabled = true
1943
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2044
testInstrumentationRunnerArguments(mapOf("clearPackageData" to "true"))
2145
}
2246
buildTypes {
2347
getByName("release") {
2448
isMinifyEnabled = true
49+
signingConfig = if (rootProject.file("$rootDir/testapp-release.keystore").exists()) {
50+
signingConfigs.getByName("release")
51+
} else {
52+
signingConfigs.getByName("debug")
53+
}
54+
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
55+
}
56+
getByName("debug") {
57+
isMinifyEnabled = false
2558
signingConfig = signingConfigs.getByName("debug")
2659
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
2760
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ buildscript {
2626
classpath(Plugins.mapboxSdkRegistry)
2727
classpath(Plugins.mapboxSdkVersionsPlugin)
2828
classpath(Plugins.pitestPlugin)
29+
classpath(Plugins.playPublisher)
2930
}
3031
}
3132

buildSrc/src/main/kotlin/Project.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ object Plugins {
2727
const val taskTreeId = "com.dorongold.task-tree"
2828
const val pitestPlugin = "pl.droidsonroids.gradle:gradle-pitest-plugin:${Versions.pitest}"
2929
const val detekt = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${Versions.detekt}"
30+
const val playPublisher = "com.github.triplet.gradle:play-publisher:${Versions.pluginPlayPublisher}"
3031
}
3132

3233
object Dependencies {
@@ -143,4 +144,5 @@ object Versions {
143144
const val pitest = "0.2.8"
144145
const val detekt = "1.20.0"
145146
const val compose = "1.1.0-beta03"
147+
const val pluginPlayPublisher = "3.7.0"
146148
}

gradle/play-publisher.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apply plugin: 'com.github.triplet.play'
2+
3+
play {
4+
track = findProperty("releaseTrack") as String ?: "internal"
5+
serviceAccountCredentials = file("test-app-play-publisher.json")
6+
defaultToAppBundles = true
7+
}

gradle/script-git-version.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
dependencies {
6+
classpath("org.ajoberstar.grgit:grgit-gradle:4.1.1")
7+
}
8+
}
9+
10+
import org.ajoberstar.grgit.Grgit
11+
12+
ext {
13+
git = Grgit.open(currentDir: projectDir)
14+
def tagSize = git.tag.list().findAll { (it.name =~ "android-v*") }.size()
15+
gitVersionCode = tagSize + 1
16+
gitVersionName = "0.1.$tagSize".toString()
17+
}

0 commit comments

Comments
 (0)