image: Visual Studio 2017
clone_folder: C:\F

environment:
  ANDROID_HOME: 'C:\Android\android-sdk'
  GRADLE_USER_HOME: 'C:\G'

init:
  - ps: |
      appveyor DownloadFile "https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip" -FileName "C:\android-tools.zip"
      Write-Host "Extracting SDK tools..."
      7z x "C:\android-tools.zip" -o"$env:ANDROID_HOME" | Out-Null

install:
  - ps: |
      Write-Output "" > ~\.android\repositories.cfg
      if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
        Write-Host "PR detected. Installing C# Script Engine and doing translations check:"
        cinst cs-script
        cscs
        cscs -ac:2 -nl $env:APPVEYOR_BUILD_FOLDER\.github\check_translations.cs
      }
      Write-Host "Installing Android packages:"
      $pkgs = '"platform-tools"', '"extras;android;m2repository"', '"extras;google;m2repository"', '"build-tools;26.0.0"', '"platforms;android-25"'
      foreach ($pkg in $pkgs) {
        Write-Host "Installing ${pkg}:"
        echo "y" | & $env:ANDROID_HOME\tools\bin\sdkmanager.bat ${pkg}
      }

build_script:
  - cmd: gradlew clean assembleDebug --stacktrace

after_build:
  - ps: Rename-Item -Path "$env:APPVEYOR_BUILD_FOLDER\app\build\outputs\apk\debug\app-debug.apk" -NewName "fasthub-debug-$env:APPVEYOR_BUILD_VERSION.apk"

test: off

artifacts:
- path: \app\build\outputs\apk\debug\fasthub-debug-%APPVEYOR_BUILD_VERSION%.apk

deploy: off

notifications:
- provider: GitHubPullRequest
  template: ':x: [Build {{&projectName}} {{buildVersion}} {{status}}]({{buildUrl}}) (commit {{commitUrl}} by @{{&commitAuthorUsername}})  <br>  <br>**Message(s):**  <br>{{#jobs}}{{#messages}}<br>{{message}}<br>{{/messages}}{{/jobs}}'
  on_build_success: false
  on_build_failure: true
  on_build_status_changed: false