diff --git a/.travis.yml b/.travis.yml index 3047d63f..4c5d189a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,13 @@ language: android + +env: + global: + # ORG_GRADLE_PROJECT_keystorePassword. + - secure: "TGGsl0Jdc6cKt0dHarl6/YobzOZTxtxGCSZiwDPZn2Qe2IAUb8JssvTviOkCtbXQesdjcHuvpVlG70Yz0sISxTanwJI6yRMmqAOm6mfr1bVvcaeFIXXEm1s8q8rQfHxOv0BTMxLQ2MdYkz6MteTOcn722e0NEs+lh73aSbCi0Os=" + + # ORG_GRADLE_PROJECT_keystoreKeyPassword. + - secure: "KbIFt5KMY6sMLsMtYQDbHUX8MtYQSY+6Lj9qc+jJdTAukc2qAtJLNyXKKQlG5pyoSN/F/hVBJKbmDDz2AY6ifMZkOpzVVKlN8E2MPG1BCln0BwMJactL1kLb+287oFg6tXDc6YoxImeKlpFMucy2RjeWwtZptmbsUiXT2UwhPn8=" + android: components: # Specify the components that are needed to build the project. @@ -16,14 +25,39 @@ android: - extra-google-m2repository - extra-android-m2repository +before_script: + # Decrypts the keystore (if this is not a PR build). + - 'if [ ${TRAVIS_SECURE_ENV_VARS} = "true" ]; then + openssl aes-256-cbc -d + -K $encrypted_d213628fe2b0_key -iv $encrypted_d213628fe2b0_iv + -in keystores/warmshowers.jks.enc -out "$HOME/warmshowers.jks" && + export ORG_GRADLE_PROJECT_keystoreFile="$HOME/warmshowers.jks"; + fi' + + # Sets the (public) keystore settings. + - export ORG_GRADLE_PROJECT_keystoreKeyAlias="wsandroid" before_cache: - # Clean up the cache. - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fR $HOME/.gradle/caches/*/plugin-resolution/ + # Cleans up the cache. + - rm -f "$HOME/.gradle/caches/modules-2/modules-2.lock" + - rm -fR "$HOME/.gradle/caches/*/plugin-resolution/" + - rm -f "$HOME/warmshowers.jks" cache: directories: - - $HOME/.android/build-cache - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ + - "$HOME/.android/build-cache" + - "$HOME/.gradle/caches/" + - "$HOME/.gradle/wrapper/" + +before_deploy: + - mv app/build/outputs/apk/app-release.apk wsandroid-$TRAVIS_TAG.apk + +deploy: + # Deploys the release APK for tagged revisions to GitHub. + provider: releases + api_key: + secure: "dIzw4tJxXLPlA7wDdcgwLop6qcAU9lPTD4Z322APx6430Pevx93o6u8H6vnNMPytbpL4kpsxQjsqe+gz3DLB5vSUmftn0UF5GrjJTxNCeSj0wxW5kgeb2iuw4UsjpoI1FOroN0FxOg+CJUoD27MRwjjl4S9NnEVYmbcj9+8O8f4=" + file: "wsandroid-$TRAVIS_TAG.apk" + skip_cleanup: true + on: + tags: true diff --git a/app/build.gradle b/app/build.gradle index 47f2a950..2da0f3b1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,13 +36,6 @@ dependencies { testCompile 'org.json:json:20170516' } - -def propertiesFile = rootProject.file("local.properties") -def properties = new Properties() -if (propertiesFile.canRead()) { - properties.load(new FileInputStream(propertiesFile)) -} - android { buildToolsVersion "26.0.0" @@ -57,14 +50,14 @@ android { } release { - if (properties['keystoreFile']) { + if (keystoreFile) { doSignRelease = true - // Set these values in local.properties - storeFile file(properties['keystoreFile']) - storePassword properties['keystorePassword'] - keyAlias properties['keyAlias'] - keyPassword properties['keyPassword'] + // Set these values in local.properties. + storeFile file(keystoreFile) + storePassword keystorePassword + keyAlias keystoreKeyAlias + keyPassword keystoreKeyPassword } } } diff --git a/build.gradle b/build.gradle index dd49c280..2740e77b 100644 --- a/build.gradle +++ b/build.gradle @@ -25,6 +25,16 @@ ext { isPreDexEnabled = "true".equals(System.getProperty("pre-dex", "true")) } +// Loads the local properties. +def localPropertiesFile = rootProject.file("local.properties") +if (localPropertiesFile.canRead()) { + def localProperties = new Properties() + localProperties.load(new FileInputStream(localPropertiesFile)) + localProperties.stringPropertyNames().each { + project.ext[it] = localProperties[it] + } +} + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/keystores/warmshowers.jks.enc b/keystores/warmshowers.jks.enc new file mode 100644 index 00000000..a5874db7 Binary files /dev/null and b/keystores/warmshowers.jks.enc differ