name: Windows Build Tests

on:
  push:
    branches-ignore:
      - master
      - release
      - gha
      - Qt4
      - Qt4-dev
    tags-ignore: '*'
    paths-ignore: '/.github/workflows/release.yml'
  pull_request:

env:
  ACTIONS_ALLOW_UNSECURE_COMMANDS: true

jobs:
  build:
    name: ${{ matrix.config.name }} Qt ${{ matrix.config.qt_version }}
    runs-on: ${{ matrix.config.os }}
    #continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name:  "Cmake : WebEngine :",
            os:    windows-2025,
            qt_version: "5.14.1",
            qt_modules: "qtwebengine",
            setup: "cmake -DUSE_STATIC_CHMLIB=ON -DUSE_WEBENGINE=ON .",
            build: "cmake --build . --config Release",
            install: "cmake --install . --config Release"
          }
        - {
            name:  "qmake : WebEngine :",
            os:    windows-2025,
            qt_version: "5.14.1",
            qt_modules: "qtwebengine",
            setup: 'qmake -r "USE_STATIC_CHMLIB=1" "USE_WEBENGINE=1" "LIBZIP_ROOT=C:/Program Files (x86)/libzip"',
            build:  "nmake",
            install: "echo skip"
          }
        - {
            name:  "Cmake : WebEngine :",
            os:    windows-2025,
            qt_version: "6.2.0",
            qt_modules: "addons.qtwebengine addons.qtwebchannel addons.qtpositioning qt5compat",
            setup: "cmake -DUSE_STATIC_CHMLIB=ON -DUSE_WEBENGINE=ON .",
            build: "cmake --build . --config Release",
            install: "cmake --install . --config Release"
          }
        - {
            name:  "qmake : WebEngine :",
            os:    windows-2025,
            qt_version: "6.2.0",
            qt_modules: "addons.qtwebengine addons.qtwebchannel addons.qtpositioning qt5compat",
            setup: 'qmake -r "USE_STATIC_CHMLIB=1" "USE_WEBENGINE=1" "LIBZIP_ROOT=C:/Program Files (x86)/libzip"',
            build:  "nmake",
            install: "echo skip"
          }

    steps:
    - name: checkout
      uses: actions/checkout@v4
      with:
        submodules: true

    - name: MSVC Environment Setup
      uses: ilammy/msvc-dev-cmd@v1

    - name: Install Qt
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.config.qt_version }}
        modules: ${{ matrix.config.qt_modules }}

    - name: Build & install zlib
      shell: bash
      run: |
        cd ../
        git clone https://github.com/madler/zlib.git
        cd zlib
        mkdir build
        cd build
        cmake ..
        cmake --build . --config Release
        cmake --install . --config Release

    - name: Build & install libzip
      shell: bash
      run: |
        cd ../
        git clone https://github.com/nih-at/libzip.git
        cd libzip
        git checkout v1.11.4
        mkdir build
        cd build
        cmake ..
        cmake --build . --config Release
        cmake --install . --config Release

    - name: Setup project
      run: ${{ matrix.config.setup }}

    - name: Build project
      run: ${{ matrix.config.build }}
      
    - name: Install project
      shell: bash
      run: ${{ matrix.config.install }}
