branches:
  only:
    - master
    - /win.*/

# Start builds on tags only
# skip_non_tags: true

environment:
  matrix:
    - MSYS2_ARCH: i686
      MSYSTEM: MINGW32

build_script:
  - set
  - set PATH=C:\msys64\%MSYSTEM%\bin;C:\msys64\usr\bin;%PATH%
  - set CHERE_INVOKING=yes
  # workaround new msys2 packagers
  - curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz
  - curl -O http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig
  - bash -lc "pacman-key --verify msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz.sig"
  - bash -lc "pacman --noconfirm  -U msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz"
  # remove precisely conflicting packages
  - bash -lc "pacman --noconfirm --ask 20 --remove mingw-w64-x86_64-gcc-ada mingw-w64-x86_64-gcc-objc mingw-w64-i686-gcc-ada mingw-w64-i686-gcc-objc"
  # workaround updating msys2-runtime breaks all programs until last one exited
  - bash -lc "pacman -Syuu --noconfirm"
  - Powershell.exe "Stop-Process -name dirmngr -Erroraction silentlycontinue; echo killing_dirmng"
  - Powershell.exe "Stop-Process -name gpg-agent -Erroraction silentlycontinue; echo killing_gpg-agent"
  - bash -lc "pacman -Syuu --noconfirm"
  - Powershell.exe "Stop-Process -name dirmngr -Erroraction silentlycontinue; echo killing_dirmng"
  - Powershell.exe "Stop-Process -name gpg-agent -Erroraction silentlycontinue; echo killing_gpg-agent"
  # finally run the install process
  - bash -lc "bash .appveyor/msys2.sh"

artifacts:
  - path: tools/win_installer/gpodder-*-contents.txt
  - path: tools/win_installer/gpodder-*-installer.exe
  - path: tools/win_installer/gpodder-*-portable.exe

deploy: off

on_failure:
  - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
