platform:
  - x64
branches:
  only:
  - master
  - /release\/.*/
environment:
  global:
    MBASH: C:\msys64\usr\bin\sh -lc
    MSYS2_FC_CACHE_SKIP: true
  matrix:
    - MSYSTEM: MINGW32
      MBITS: 32
for:
  -
    branches:
      only:
        - /release\/.*/
    environment:
      global:
        APPVEYOR_CONFIG_PROD: 1
      matrix: # This extends the default, so 32 bit is still built
        - MSYSTEM: MINGW64
          MBITS: 64

clone_depth: 10

#The cache is slightly slower than just downloading the files
#cache:
#  - 'C:\msys64\var\cache\pacman\pkg'
install:
  - git clone --depth=1 --branch=master https://github.com/fontforge/fontforgebuilds.git
  - >-
    move C:\msys64 C:\msys64_old &&
    curl -kLo msys2.tar.xz https://github.com/msys2/msys2-installer/releases/download/nightly-x86_64/msys2-base-x86_64-latest.tar.xz &&
    7z x -so msys2.tar.xz | 7z x -si -ttar &&
    move msys64 C:\ && del msys2.tar.xz &&
    call %MBASH% "ls
  - call %MBASH% "pacman -Syuu --noconfirm"
  - taskkill /f /fi "MODULES eq msys-2.0.dll" || exit /b 0
  - call %MBASH% "pacman -Suu --noconfirm"
  - call %MBASH% "pacman -Suu --noconfirm" 
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; ./ffbuild.sh --appveyor --depsonly"
build_script:
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; ./ffbuild.sh --appveyor"
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; FFPATH=`cygpath -m $APPVEYOR_BUILD_FOLDER` ./make-portable-package.sh appveyor"
  - if "%APPVEYOR_REPO_BRANCH:~0,8%"=="release/" cd "%APPVEYOR_BUILD_FOLDER%/fontforgebuilds/fontforge-setup" && "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" -Qp fontforgesetup.iss
test: off
artifacts:
  - path: fontforgebuilds\*-appveyor.7z
    name: FontForge $(MBITS)-bit build
  - path: fontforgebuilds\*-debugging-symbols.7z
    name: FontForge $(MBITS)-bit debugging symbols
  - path: fontforgebuilds\fontforge-setup\*.exe
    name: FontForge $(MBITS)-bit setup
#on_failure:
#  - cat build/CMakeCache.txt || true
#  - cat build/CMakeFiles/CMakeOutput.log || true
#  - cat build/Testing/Temporary/LastTest.log || true
#  - cat build/build.ninja || true
