Skip to content

Commit 54f434d

Browse files
authored
Added automatic releases to Github and Google Play (#52)
This PR adds automatic deployment of tagged releases to Github Releases and Google Play. Credentials are encrypted into .travis.yml using the Travis private key.
1 parent 9ef157e commit 54f434d

File tree

6 files changed

+79
-14
lines changed

6 files changed

+79
-14
lines changed

.travis.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,36 @@ language: android
33
jdk: oraclejdk8
44
android:
55
components:
6-
- platform-tools
7-
- tools
8-
- build-tools-25.0.2
9-
- android-25
10-
- extra-google-m2repository
11-
- extra-android-m2repository
12-
script: './gradlew build check'
6+
- platform-tools
7+
- tools
8+
- build-tools-25.0.2
9+
- android-25
10+
- extra-google-m2repository
11+
- extra-android-m2repository
12+
env:
13+
global:
14+
- ANDROID_PLAY_JSON_FILE="../creds/google-play.json"
15+
- ANDROID_RELEASE_STORE_FILE="../creds/platypus-android.jks"
16+
- secure: eHqN5ncAt4zJMM5OR+wQqn6WRiNEJx/MKZtO1BpkfOQVW67U0a7ZDQ2LF3tqlfJBRnW/4E9BJysi15WKigjHpeaPNVZh2V9cb2vejUd0P/DZZHYYcFvyoXh9R0ZnfJNr1Ui9q6Ll7kgSxgsOa5UrNMP4Q8vraw+fijEdMyh4yvU=
17+
- secure: D0uqmhG2Rit16cbHwjvZhXG0caS0RxOZvQaP1nQtLIfq0uPWU/mDqv6gVHnpuZpxIuIKuMRe+MOZvSDuT6LhZLzXVs43Ikzrq7Yr4yNr16Nwo2//qv9B2OxuepunlduCv8B95lJQX5S9zjAAl7e1eQMXphC3IsDs4nbd7pDpRmk=
18+
- secure: VKHCNY+p91IDd3AZl/FGUHkokAZLkx0tlwRh9u9jHksVky2PFLDrOYU9yF2BPvs2QlSbCdVF/+/TyaImZmZ0e5XJAocjM4Ew2z9QbMiuo8KMtzixni/iINRQlEVNOZRCOHcOhnBCccteYk9kQ1oRB56AXoukzmscco2d1Bx7sgk=
19+
before_install:
20+
- openssl aes-256-cbc -K $encrypted_3a18627f5297_key -iv $encrypted_3a18627f5297_iv
21+
-in secrets.tar.enc -out secrets.tar -d
22+
- tar xvf secrets.tar
23+
script: "./gradlew build check"
24+
deploy:
25+
- provider: releases
26+
api_key:
27+
secure: SzonDecstyEHJuiuYeHisXsXWPIRFvIdali89uGo4lfzQ5E0+zqzyMJR4B8eyFiVn0VXCCGaUj9IUFRHGjlEafWmv+YFyAC2doZwOk4EKq2ZcK85XAUyLQEA6X1RrKUx11VSxn5gxtXA/4fyarv139PzELQw3liNIVPx44CipiA=
28+
file: app/build/outputs/apk/app-release.apk
29+
skip_cleanup: true
30+
on:
31+
repo: platypusllc/server
32+
tags: true
33+
- provider: script
34+
script: "./gradlew publishApkRelease"
35+
skip_cleanup: true
36+
on:
37+
repo: platypusllc/server
38+
tags: true

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,20 @@ controlling the platforms using high-level commands.
88

99
----
1010

11-
Code in this repository is automatically built by Travis-CI. The `master`
12-
branch is compiled to an APK and uploaded to the Google Play store.
11+
Code in this repository is automatically built by Travis-CI. Any tags of this
12+
repostory will be automatically compiled to an APK and uploaded both named
13+
Github Releases and the `alpha` channel on the Google Play store.
14+
15+
In order to do signed builds, the following environment variables must be set:
16+
```
17+
ANDROID_PLAY_JSON_FILE
18+
ANDROID_RELEASE_STORE_FILE
19+
ANDROID_RELEASE_STORE_PASSWORD
20+
ANDROID_RELEASE_KEY_ALIAS
21+
ANDROID_RELEASE_KEY_PASSWORD
22+
```
23+
24+
This deployment is based on the following setups:
25+
- https://github.com/codepath/android_guides/wiki/Automating-Publishing-to-the-Play-Store
26+
- https://github.com/larsgrefer/bpm-meter-android/blob/master/.travis.yml
27+
- https://github.com/Triple-T/gradle-play-publisher

app/build.gradle

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'com.github.triplet.play'
23

34
repositories {
45
mavenCentral()
@@ -11,32 +12,52 @@ android {
1112
compileSdkVersion 25
1213
buildToolsVersion "25.0.2"
1314

15+
playAccountConfigs {
16+
release {
17+
jsonFile = file(System.getenv("ANDROID_PLAY_JSON_FILE") ?: ".")
18+
}
19+
}
20+
signingConfigs {
21+
release {
22+
keyAlias System.getenv("ANDROID_RELEASE_KEY_ALIAS") ?: "EXAMPLE_ALIAS"
23+
keyPassword System.getenv("ANDROID_RELEASE_KEY_PASSWORD") ?: "EXAMPLE_PASSWORD"
24+
storeFile file(System.getenv("ANDROID_RELEASE_STORE_FILE") ?: ".")
25+
storePassword System.getenv("ANDROID_RELEASE_STORE_PASSWORD") ?: "EXAMPLE_PASSWORD"
26+
v2SigningEnabled true
27+
}
28+
}
1429
defaultConfig {
1530
applicationId "com.platypus.android.server"
1631
minSdkVersion 21
1732
targetSdkVersion 25
18-
versionCode 1
19-
versionName "1.0"
33+
versionCode 3
34+
versionName "1.3"
35+
playAccountConfig = playAccountConfigs.release
2036
}
2137
buildTypes {
2238
release {
2339
minifyEnabled false
2440
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
41+
signingConfig signingConfigs.release
2542
}
2643
}
2744
lintOptions {
2845
abortOnError false
2946
}
3047
dexOptions {
31-
javaMaxHeapSize '3g'
48+
javaMaxHeapSize '4g'
3249
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
3350
// See: https://guides.codepath.com/android/Setting-up-Travis-CI
3451
preDexLibraries = preDexEnabled && !travisBuild
3552
}
3653
}
3754

55+
play {
56+
track = 'alpha'
57+
untrackOld = true
58+
}
59+
3860
dependencies {
39-
compile fileTree(dir: 'libs', include: ['*.jar'])
4061
testCompile 'junit:junit:4.12'
4162
compile 'com.android.support:appcompat-v7:24.0.0'
4263
compile 'com.android.support:support-v13:24.0.0'

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ buildscript {
1212

1313
// Google Services are required to support Firebase.
1414
classpath 'com.google.gms:google-services:3.0.0'
15+
16+
// Add gradle-play-publisher to deploy to Google Play store.
17+
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
1518
}
1619
}
1720

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# The setting is particularly useful for tweaking memory settings.
1212
# Default value: -Xmx10248m -XX:MaxPermSize=256m
1313
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14-
org.gradle.jvmargs=-Xmx3g
14+
org.gradle.jvmargs=-Xmx4g
1515

1616
# When configured, Gradle will run in incubating parallel mode.
1717
# This option should only be used with decoupled projects. More details, visit

secrets.tar.enc

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)