cache:
  yarn: true
  directories:
    - $HOME/.yarn-cache
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
    - node_modules
branches:
  only:
  - master
  - develop
notifications:
  email:
    on_success: never
    on_failure: always
  slack:
    secure: aR7CUgdWuAU+fthj50nD4k4PwC0lN3Ul5uIrb90Pv57kgm450Jp1h/pNcF/x+KayXWua+K009AG3AA/ginQhNvds0N12pnADC1lvGALaBtcfGJpElhHUSgvhkV/DbDcgkhmQibZfeR/D29yESsZ9PZ0qNKqK6z9AiQQlFS6Rogq/IUNRfC1GD472s/evCDek07Ywka7bNkIUaOXsI19R8cKj2bsC0jJRV+F0LMYLpjC4uBCOo57P9giLPA5+hGx6wrjmIo94S3H1wWXSJjua/JA7Ixqx34CyUJ1vLfEAeQppX0p5Zln/H2qhcve1ECCpMvQm2AFnE1IHoIZS9esx4qJWGpSfvqPuOY4QRnKN0IwjzSXPVMhkXXRnU7GYKHGtEQkQUhEGApVCezutQBkSDViy5oY4PDctFHuXprZWYIHiel6gZksM5891w2DSXsHsc99PQZpBEM+1/bkkN42PzYJocq13Iz79ncsGn4iWSbnqSGVJMj43sna3CaXxoH2hfQoiYUjCeXmpqfTbay36lf6UMu8it/IyJOHdhKxmkVlN+BVeExBYdVMgE0Mbw2ZbeXaOW2BPXeE3Y20UtNvCAqDY4jzvfRj3mJIdqPvK4aj1wTh+aF/wGGXkQ96ZpL5P34LH1aRvv9WFpikjuqKhIpcuqzSpRFdu977yCPqe+BE=

matrix:
  include:
    - language: android
      jdk: oraclejdk8
      sudo: required
      dist: precise
      before_cache:
        - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
        - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
      android:
        components:
          - tools
          - tools #Call it again so it installs the tools
          - build-tools
          - platform-tools
          - build-tools-27.0.3
          - android-27
          - add-on
          - extra-android-m2repository
          - extra-google-google_play_services
          - extra-google-m2repository
      licenses:
        - android-sdk-preview-license-.+
        - android-sdk-license-.+
        - google-gdk-license-.+
      before_install:
        - yes | sdkmanager "platforms;android-27" "build-tools;27.0.3" "build-tools;27.0.0"
        - nvm install 8.10.0
        - node --version
        - travis_retry curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
        - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
        - travis_retry sudo apt-get update -qq
        - travis_retry sudo apt-get install -y -qq yarn
        - gem install fastlane --no-rdoc --no-ri --no-document --quiet
        - chmod +x ./android/gradlew
        - openssl aes-256-cbc -K $encrypted_70d456c9569f_key -iv $encrypted_70d456c9569f_iv -in ./android/app/releaseFiles.tar.enc -out ./android/app/releaseFiles.tar -d
        - tar xvf ./android/app/releaseFiles.tar -C ./android/app
        # - security delete-certificate -c "Apple Worldwide Developer Relations Certification Authority" # add this to resolve 'Could not install WWDR certificate'
      install:
        - yarn install
      script:
        - cd android && ./gradlew clean
        - if [ "$TRAVIS_BRANCH" = "develop" ]; then
            fastlane alpha_googleplay;
            fastlane alpha_crashlytics;
          fi
        - if [ "$TRAVIS_BRANCH" = "master" ]; then fastlane release; fi

    - language: objective-c
      os: osx
      osx_image: xcode9.2
      node_js: false
      before_install:
        - nvm install 8.10.0
        - node --version
        - travis_retry npm install -g yarn
        - yarn -version
        - gem install fastlane --no-rdoc --no-ri --no-document --quiet
        - openssl aes-256-cbc -K $encrypted_5a0bd94d6bee_key -iv $encrypted_5a0bd94d6bee_iv -in .deploy_key.enc -out ~/.ssh/deploy_key -d
        - echo -e "Host github.com\n\tHostName github.com\n\tUser git\n\tIdentityFile ~/.ssh/deploy_key\n" >> ~/.ssh/config
        - ssh-keyscan github.com >> ~/.ssh/known_hosts
        - chmod 600 ~/.ssh/deploy_key
      install:
        - travis_retry yarn
      script:
        - cd ios
        # We don't need to check for release branch here because alpha/beta are all handled in TestFlight
        - if [ "$TRAVIS_BRANCH" = "develop" ]; then fastlane alpha_testflight; fi
        - if [ "$TRAVIS_BRANCH" = "master" ]; then fastlane release; fi
