language: android
dist: trusty
android:
  components:
  - platform-tools
  - tools
  - build-tools-27.0.3
  - android-25
  - extra-google-m2repository
  - extra-android-m2repository
  licenses:
  - android-sdk-preview-license-.+
  - android-sdk-license-.+
sudo: false
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:
- GIT_HASH=`git log --pretty=format:'%h' -n 1`
- GIT_BUILD=`git describe --all --always`-$GIT_HASH
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
- chmod +x shell/android-studio/gradlew
install:
- sudo apt-get -qq update
- touch ~/.android/repositories.cfg
- echo y | sdkmanager 'ndk-bundle'
- export NDK=ANDROID_NDK=ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
- export PATH=${PATH}:$ANDROID_HOME/tools
- export PATH=${PATH}:$ANDROID_HOME/platform-tools
- export PATH=${PATH}:$NDK
- mkdir -p ~/.android
before_script: 
script:
- git fetch --depth 250
- cd shell/android-studio
- export NUMBER_OF_PROCESSORS=2
- sudo chmod 755 travis-build.sh
- "./travis-build.sh"
before_deploy:
- cd ../../
- mkdir -p artifacts/$GIT_BUILD/
- cp shell/android-studio/reicast/build/outputs/apk/dreamcast/debug/reicast-dreamcast-debug.apk artifacts/$GIT_BUILD/flycast-debug-$GIT_HASH.apk
deploy:
  provider: s3
  access_key_id: AKIAJOZQS4H2PHQWYFCA
  secret_access_key:
    secure: $S3_SECRET_KEY
  bucket: flycast-builds
  local-dir: artifacts
  upload-dir: android
  acl: public_read
  skip_cleanup: true
  on:
    all_branches: true
repo: flyinghead/flycast

