name: windows_ci

on: [push, pull_request]

jobs:
  build-native:
    strategy:
      matrix:
        os: [windows-2019, windows-2022]
        arch: [Win32, x64, ARM64]
        include:
          - generator: "Visual Studio 16 2019"
            os: windows-2019
          - generator: "Visual Studio 17 2022"
            os: windows-2022
    runs-on: ${{ matrix.os }}
    continue-on-error: false
    name: ${{ matrix.os }} - ${{ matrix.arch }}
    steps:
      - uses: msys2/setup-msys2@v2
        with:
          update: true
          install: >-
            autoconf
            automake
            diffutils
            libtool
            gcc
            git
            patch
            perl
      - uses: actions/checkout@main
      - shell: msys2 {0}
        run: ./autogen.sh
      - shell: cmd
        run: cmake -Bbuild -G "${{ matrix.generator }}" -A ${{ matrix.arch }} -DCMAKE_INSTALL_PREFIX=../local
      - shell: cmd
        run: cmake --build build --config Release
      - shell: cmd
        if: ${{ matrix.arch != 'ARM64' }}
        run: ctest --test-dir build -C Release --output-on-failure
      - uses: actions/upload-artifact@v3
        with:
          name: windows-build-results-${{ matrix.os }}-${{ matrix.arch }}
          path: build
