Skip to content

Commit 5eb8da9

Browse files
authored
Merge pull request #27 from medic/16-automate-build-pr
Build, sign, and deploy commits with tag v0.0.0
2 parents 56409dd + b245066 commit 5eb8da9

File tree

8 files changed

+137
-5
lines changed

8 files changed

+137
-5
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,10 @@ $RECYCLE.BIN/
189189

190190

191191
# End of https://www.gitignore.io/api/macos,opencv,windows,androidstudio
192+
193+
secrets.tar.gz
194+
medic-official.keystore
195+
playstore-secret.json
196+
197+
fastlane/*
198+
!fastlane/Fastfile

.travis.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
language: android
2+
dist: trusty
3+
jdk: oraclejdk8
4+
android:
5+
components:
6+
- tools
7+
- platform-tools
8+
- build-tools-28.0.2
9+
- android-28
10+
- extra-android-m2repository
11+
- extra-google-m2repository
12+
env:
13+
- GRADLE_OPTS="-XX:MaxPermSize=2048M"
14+
before_install:
15+
- openssl aes-256-cbc -K $encrypted_d751a50dc857_key -iv $encrypted_d751a50dc857_iv -in secrets.tar.gz.enc -out secrets.tar.gz -d
16+
- tar -xf ./secrets.tar.gz
17+
- gem update --system
18+
- gem install fastlane --no-document --quiet
19+
install:
20+
- echo y | sdkmanager "ndk-bundle"
21+
- echo y | sdkmanager "cmake;3.6.4111459"
22+
- echo y | sdkmanager --channel=3 --channel=1 "cmake;3.10.2.4988404"
23+
before_script:
24+
- export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
25+
stages:
26+
- name: test
27+
- name: deploy
28+
if: tag IS present
29+
jobs:
30+
include:
31+
- stage: test
32+
script: ./gradlew --daemon --parallel test
33+
- stage: deploy
34+
script: fastlane deploy
35+
before_cache:
36+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
37+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
38+
cache:
39+
directories:
40+
- "$HOME/.gradle/caches/"
41+
- "$HOME/.gradle/wrapper/"
42+
- "$HOME/.android/build-cache"
43+
deploy:
44+
provider: releases
45+
skip_cleanup: true
46+
overwrite: true
47+
api_key:
48+
secure: oaUQr+Kn8Eikrlc5Hwo5NVn/4W+xc6VdcYdBHpOEC6Oi+oO5Yp/hNZMUxg7DKBJs9moRRGfqdFhFIj5XO6hCYgJgPOA6ZC51nOQzkNoYgWwPAKf6PvCu8JQ25XTMVc9nCyHTz7LcP3cxYKSaOZt0IAYCKeBjogPJQ4dtNSvFmy0WAx4OYBHj+P0djWWHi2XlBLRsaRn430b+XyHooeOiSbOtgOT5Vk3vcruCaojL0uat3f+384yyD140qKspJ568OqF/wCzuAK8N3ex3MFXU6Giv9JdUA+ZDLhFN2lHMK7cqUaCqsAxF2gYyUNSXoG+RptBDtqn5JsqmsoMgtJW6ygcIHoC4Q6IIEtz/jUiueOnLuu2MB4e6+ft3MZfjaztnSrMjRXdU5ewv9avv70Ibh8mhDNxOBRqgbtDTR5tdNTwiyaBIY0D9nbzrNw1HU5Ti74KvAvOLA/k6kuO5/9t9V2j8HbUOfh08EttqUB4brDBVnpwZwxhDkrMfSkJJHd7Z7mBo2nsDMBG1xGQ12ZD0YCOj/QV/nm4+KeUeWEIwqj76E8y8/z+n49JcjhejK486oLI1/bOKufX9MQeAXNqBKKLIZDwzDRbBhVq9tulbw4IsA374PspQE1e0zxzOFNnahTFbrOTaLiMSqiEjjLLHx/piLKd5QyV0dWDP97iGhVA=
49+
file_glob: true
50+
file: ./app/build/outputs/apk/**/*.apk
51+
on:
52+
repo: medic/rdt-capture
53+
branch: master

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The current version is <a href="https://play.google.com/store/apps/details?id=ed
77

88
**Please note that the app has not yet been clinically validated.**
99

10+
## Publishing
11+
Create a git tag starting with v, e.g. v1.2.3 and push the tag to GitHub.
12+
13+
Creating this tag will trigger a Travis CI to build, sign, and version a new release. The release-ready APKs are available for side-loading from GitHub Releases and are uploaded to the Google Play Console in the "alpha" channel. To release to the public, click "Release to Production" or "Release to Beta" via the Google Play Console.
14+
1015
## License
1116
The software is provided under [BSD-3-Clause](LICENSE). Contributions to this project are accepted under the same license.
1217

app/build.gradle

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,64 @@
11
apply plugin: 'com.android.application'
22

3+
def getVersionCode = {
4+
int versionCode = 1
5+
if(System.env.TRAVIS == 'true' && System.env.TRAVIS_TAG && System.env.TRAVIS_TAG.startsWith('v')) {
6+
def versionParts = System.env.TRAVIS_TAG.split(/[\.v]/)
7+
8+
if (versionParts.length != 4)
9+
throw new RuntimeException("Unexpected version number - should be of formatted as 'v0.0.0', but was: $System.env.TRAVIS_TAG")
10+
11+
versionParts = versionParts.drop(1).collect { Integer.parseInt(it) }
12+
13+
if (versionParts[1] > 999 || versionParts[2] > 999)
14+
throw new RuntimeException('Version part greater than 999 not allowed.')
15+
16+
versionCode = (1000 * 1000 * versionParts[0]) + 1000 * versionParts[1] + versionParts[2]
17+
if (versionCode > 2100000000 / 10)
18+
throw new RuntimeException('versionCode bigger than max allowed by Google Play.')
19+
}
20+
21+
return versionCode
22+
}
23+
24+
def getVersionName = {
25+
System.env.TRAVIS_TAG ?: 'SNAPSHOT'
26+
}
27+
328
android {
429
compileSdkVersion 26
530
defaultConfig {
631
applicationId "edu.washington.cs.ubicomplab.rdt_reader"
732
minSdkVersion 21
833
targetSdkVersion 26
9-
versionCode 1
10-
versionName "1.0"
34+
versionCode getVersionCode()
35+
versionName getVersionName()
36+
archivesBaseName = "${project.name}-${versionName}"
1137
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1238
externalNativeBuild {
1339
cmake {
1440
cppFlags ""
1541
}
1642
}
1743
}
44+
45+
signingConfigs {
46+
release {
47+
storeFile file(System.env.ANDROID_KEYSTORE_PATH ?: signingConfigs.debug.storeFile)
48+
storePassword System.env.ANDROID_KEYSTORE_PASSWORD ?: signingConfigs.debug.storePassword
49+
keyAlias System.env.ANDROID_KEY_ALIAS ?: signingConfigs.debug.keyAlias
50+
keyPassword System.env.ANDROID_KEY_PASSWORD ?: signingConfigs.debug.keyPassword
51+
}
52+
}
53+
1854
buildTypes {
1955
release {
2056
minifyEnabled false
2157
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
58+
signingConfig signingConfigs.release
2259
}
2360
}
61+
2462
externalNativeBuild {
2563
cmake {
2664
path "CMakeLists.txt"

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.0.1'
10+
classpath 'com.android.tools.build:gradle:3.3.2'
1111

1212

1313
// NOTE: Do not place your application dependencies here; they belong

fastlane/Fastfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file contains the fastlane.tools configuration
2+
# You can find the documentation at https://docs.fastlane.tools
3+
#
4+
5+
default_platform(:android)
6+
7+
platform :android do
8+
desc "Build and deploy on Google Play"
9+
lane :deploy do
10+
gradleTaskName = "assembleRelease"
11+
version = ENV['TRAVIS_TAG'].empty? ? 'SNAPSHOT' : ENV['TRAVIS_TAG']
12+
13+
gradle(task: gradleTaskName)
14+
15+
supply(
16+
package_name: "edu.washington.cs.ubicomplab.rdt_reader",
17+
track: "alpha",
18+
json_key: "playstore-secret.json",
19+
apk: "app/build/outputs/apk/release/app-#{version}-release.apk",
20+
skip_upload_aab: true,
21+
skip_upload_metadata: true,
22+
skip_upload_images: true,
23+
skip_upload_screenshots: true,
24+
validate_only: false,
25+
26+
timeout: 3600,
27+
)
28+
end
29+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jan 12 17:07:22 PST 2018
1+
#Fri Jun 21 02:12:19 PDT 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

secrets.tar.gz.enc

4.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)