Skip to content

Commit

Permalink
Merge pull request #27 from medic/16-automate-build-pr
Browse files Browse the repository at this point in the history
Build, sign, and deploy commits with tag v0.0.0
  • Loading branch information
cjpark87 authored Jun 26, 2019
2 parents 56409dd + b245066 commit 5eb8da9
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,10 @@ $RECYCLE.BIN/


# End of https://www.gitignore.io/api/macos,opencv,windows,androidstudio

secrets.tar.gz
medic-official.keystore
playstore-secret.json

fastlane/*
!fastlane/Fastfile
53 changes: 53 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
language: android
dist: trusty
jdk: oraclejdk8
android:
components:
- tools
- platform-tools
- build-tools-28.0.2
- android-28
- extra-android-m2repository
- extra-google-m2repository
env:
- GRADLE_OPTS="-XX:MaxPermSize=2048M"
before_install:
- openssl aes-256-cbc -K $encrypted_d751a50dc857_key -iv $encrypted_d751a50dc857_iv -in secrets.tar.gz.enc -out secrets.tar.gz -d
- tar -xf ./secrets.tar.gz
- gem update --system
- gem install fastlane --no-document --quiet
install:
- echo y | sdkmanager "ndk-bundle"
- echo y | sdkmanager "cmake;3.6.4111459"
- echo y | sdkmanager --channel=3 --channel=1 "cmake;3.10.2.4988404"
before_script:
- export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
stages:
- name: test
- name: deploy
if: tag IS present
jobs:
include:
- stage: test
script: ./gradlew --daemon --parallel test
- stage: deploy
script: fastlane deploy
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
- "$HOME/.android/build-cache"
deploy:
provider: releases
skip_cleanup: true
overwrite: true
api_key:
secure: oaUQr+Kn8Eikrlc5Hwo5NVn/4W+xc6VdcYdBHpOEC6Oi+oO5Yp/hNZMUxg7DKBJs9moRRGfqdFhFIj5XO6hCYgJgPOA6ZC51nOQzkNoYgWwPAKf6PvCu8JQ25XTMVc9nCyHTz7LcP3cxYKSaOZt0IAYCKeBjogPJQ4dtNSvFmy0WAx4OYBHj+P0djWWHi2XlBLRsaRn430b+XyHooeOiSbOtgOT5Vk3vcruCaojL0uat3f+384yyD140qKspJ568OqF/wCzuAK8N3ex3MFXU6Giv9JdUA+ZDLhFN2lHMK7cqUaCqsAxF2gYyUNSXoG+RptBDtqn5JsqmsoMgtJW6ygcIHoC4Q6IIEtz/jUiueOnLuu2MB4e6+ft3MZfjaztnSrMjRXdU5ewv9avv70Ibh8mhDNxOBRqgbtDTR5tdNTwiyaBIY0D9nbzrNw1HU5Ti74KvAvOLA/k6kuO5/9t9V2j8HbUOfh08EttqUB4brDBVnpwZwxhDkrMfSkJJHd7Z7mBo2nsDMBG1xGQ12ZD0YCOj/QV/nm4+KeUeWEIwqj76E8y8/z+n49JcjhejK486oLI1/bOKufX9MQeAXNqBKKLIZDwzDRbBhVq9tulbw4IsA374PspQE1e0zxzOFNnahTFbrOTaLiMSqiEjjLLHx/piLKd5QyV0dWDP97iGhVA=
file_glob: true
file: ./app/build/outputs/apk/**/*.apk
on:
repo: medic/rdt-capture
branch: master
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The current version is <a href="https://play.google.com/store/apps/details?id=ed

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

## Publishing
Create a git tag starting with v, e.g. v1.2.3 and push the tag to GitHub.

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.

## License
The software is provided under [BSD-3-Clause](LICENSE). Contributions to this project are accepted under the same license.

Expand Down
42 changes: 40 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,64 @@
apply plugin: 'com.android.application'

def getVersionCode = {
int versionCode = 1
if(System.env.TRAVIS == 'true' && System.env.TRAVIS_TAG && System.env.TRAVIS_TAG.startsWith('v')) {
def versionParts = System.env.TRAVIS_TAG.split(/[\.v]/)

if (versionParts.length != 4)
throw new RuntimeException("Unexpected version number - should be of formatted as 'v0.0.0', but was: $System.env.TRAVIS_TAG")

versionParts = versionParts.drop(1).collect { Integer.parseInt(it) }

if (versionParts[1] > 999 || versionParts[2] > 999)
throw new RuntimeException('Version part greater than 999 not allowed.')

versionCode = (1000 * 1000 * versionParts[0]) + 1000 * versionParts[1] + versionParts[2]
if (versionCode > 2100000000 / 10)
throw new RuntimeException('versionCode bigger than max allowed by Google Play.')
}

return versionCode
}

def getVersionName = {
System.env.TRAVIS_TAG ?: 'SNAPSHOT'
}

android {
compileSdkVersion 26
defaultConfig {
applicationId "edu.washington.cs.ubicomplab.rdt_reader"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode getVersionCode()
versionName getVersionName()
archivesBaseName = "${project.name}-${versionName}"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}

signingConfigs {
release {
storeFile file(System.env.ANDROID_KEYSTORE_PATH ?: signingConfigs.debug.storeFile)
storePassword System.env.ANDROID_KEYSTORE_PASSWORD ?: signingConfigs.debug.storePassword
keyAlias System.env.ANDROID_KEY_ALIAS ?: signingConfigs.debug.keyAlias
keyPassword System.env.ANDROID_KEY_PASSWORD ?: signingConfigs.debug.keyPassword
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

externalNativeBuild {
cmake {
path "CMakeLists.txt"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.2'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
29 changes: 29 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#

default_platform(:android)

platform :android do
desc "Build and deploy on Google Play"
lane :deploy do
gradleTaskName = "assembleRelease"
version = ENV['TRAVIS_TAG'].empty? ? 'SNAPSHOT' : ENV['TRAVIS_TAG']

gradle(task: gradleTaskName)

supply(
package_name: "edu.washington.cs.ubicomplab.rdt_reader",
track: "alpha",
json_key: "playstore-secret.json",
apk: "app/build/outputs/apk/release/app-#{version}-release.apk",
skip_upload_aab: true,
skip_upload_metadata: true,
skip_upload_images: true,
skip_upload_screenshots: true,
validate_only: false,

timeout: 3600,
)
end
end
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 12 17:07:22 PST 2018
#Fri Jun 21 02:12:19 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Binary file added secrets.tar.gz.enc
Binary file not shown.

0 comments on commit 5eb8da9

Please sign in to comment.