# Based on the "trust" template v0.1.2
# https://github.com/japaric/trust/tree/v0.1.2

environment:
  global:
    RUST_VERSION: stable

    CRATE_NAME: so

  matrix:
    # MinGW
    - TARGET: i686-pc-windows-gnu
    - TARGET: x86_64-pc-windows-gnu

    # MSVC
    - TARGET: i686-pc-windows-msvc
    - TARGET: x86_64-pc-windows-msvc

install:
  - ps: >-
      If ($env:TARGET -eq 'x86_64-pc-windows-gnu') {
        $env:PATH += ';C:\msys64\mingw64\bin'
      } ElseIf ($env:TARGET -eq 'i686-pc-windows-gnu') {
        $env:PATH += ';C:\msys64\mingw32\bin'
      }
  - curl -sSf -o rustup-init.exe https://win.rustup.rs/
  - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
  - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
  - rustc -Vv
  - cargo -V

test_script:
  # we don't run the "test phase" when doing deploys
  - if [%APPVEYOR_REPO_TAG%]==[false] (
      cargo build --no-default-features --features windows --features reqwest/native-tls-vendored --target %TARGET% &&
      cargo build --no-default-features --features windows --features reqwest/native-tls-vendored  --target %TARGET% --release &&
      cargo test --no-default-features --features windows --features reqwest/native-tls-vendored  --target %TARGET%
    )

before_deploy:
  - cargo rustc --no-default-features --features windows --features reqwest/native-tls-vendored --target %TARGET% --release --bin %CRATE_NAME% -- -C lto
  - ps: ci\before_deploy.ps1

deploy:
  artifact: /.*\.zip/
  auth_token:
    secure: UTTZXiJCZo8UF4H4xvBe7SyC40UKviK1Z7qzR3mThCIg7WuIKuLLjbxM0NEomrZE
  description: ''
  on:
    RUST_VERSION: stable
    appveyor_repo_tag: true
  provider: GitHub

cache:
  - C:\Users\appveyor\.cargo\registry
  - target

branches:
  only:
    # Release tags
    - /^v\d+\.\d+\.\d+.*$/
    - master
    - develop

notifications:
  - provider: Email
    to:
      - sam.chong.tay@gmail.com
    on_build_success: false

# Building is done in the test phase, so we disable Appveyor's build phase.
build: false
