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
# These steps will update msys2 to the latest version
# Run unconditionally if builds fail because of pacman not installing dependencies due to version conflicts
  - >-
    if "%APPVEYOR_REPO_BRANCH:~0,8%"=="release/"
    move C:\msys64 C:\msys64_old &&
    curl -ko msys2.tar.xz http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.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" &&
    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
