language: android
dist: trusty
if: tag != 'tip'

android:
  components:
    - platform-tools
    - tools
    - build-tools-29.0.3
    - android-29

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"

before_install:
  - yes | sdkmanager ndk-bundle 'ndk;21.3.6528147'
  - openssl aes-256-cbc -K $encrypted_532b6bc7108c_key -iv $encrypted_532b6bc7108c_iv -in dist/apognu.jks.enc -out dist/apognu.jks -d
  - echo -e "signing.store=/home/travis/build/apognu/otter/dist/apognu.jks\nsigning.key_passphrase=${keystore_passphrase}\nsigning.alias=release\nsigning.store_passphrase=${keystore_passphrase}" > local.properties

script:
  - "./gradlew app:assembleRelease"

before_deploy:
  - RELEASE_MESSAGE="$(git tag -ln --format '%(subject)' $TRAVIS_TAG)"

deploy:
  - provider: releases
    name: $TRAVIS_TAG
    body: $RELEASE_MESSAGE
    prerelease: false
    file: app/build/outputs/apk/release/app-release.apk
    overwrite: true
    skip_cleanup: true
    on:
      tags: true
    api_key:
      secure: CIgVCinr1VDsMAAjcU8rxVq5SA0kDK3yTmtZW8Hc5RoOhVlKH24VWzdIjWdPZyW3vEDSPlBehAoSCDFI7oZ8xH/SgeXIdFMFbpCUi7QXp+ZdK8MdduHsXXVsEvVlIKi4R8ZhpFF/oR/yKwUo3zDT3SNv5zKZQvae+OzWIt9hm95gm9A+HexgdG4NjjtaNNp+wmhWEO8BvyZV6ZN05o+Z/qQz5pHc8n/v4sLcaQltnErZBaW4wBKKIvwZ54TQrWewW2y2m2lARKt8IGcgWW1jwQD7rzP1hzz/UGLF0eMbFCHNm+r8go0YoB7UDXKfmsZuDsFhjqpQuP3rOlavtXdBB1wAfsbJB3u1mso54w9/M9r1hRK2oClmhLOKU4wYzHLhwwa658qcbTDCJ2+Zwf81/D2YADj3hAkCdpoc0hJoEKQXRdhnQ0yiqYy4p/3RYh7WqSsU7iwUCqyDVHVprv89Qh5iPdbxezYpXQVWyeLpy4+4cYWqjggyxBy0wz7LUu9uClg2M2uaFZ/Ud1FOqtHeDP+Q8hW0DcArYPHXVAySyiuNXAhS/SWFnmpuCtzCs5NmnYA9lmYr33u3+rDJ9+LHArFXTVdfxU2xaSsG0kyjNVxKa3UXEoz0tqBJpeihkWGtjq04sK2AeEEw8lAt6wafFY6jMra23qPQRTCBNPuUsqk=
