name: 'Build'

on:
  push:
    branches:
      - '**'
    tags-ignore:
      - '*'
  pull_request:
  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.experimental }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        # Linux:   https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/
        # macOS:   https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/
        # Windows: https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/
        qt-version: ['5.9.9', '5.13.2', '5.14.2', '5.15.2', '6.4.2', '6.5.0', '6.6.0', '6.10.1']
        experimental: [false]
        exclude:
          # win64_mingw73 not found
          - os: windows-latest
            qt-version: '5.15.0'
          # 'D:\\a\\qmarkdowntextedit/Qt\\5.9.9\\mingw73_64\\bin\\qt.conf' not found
          - os: windows-latest
            qt-version: '5.9.9'
          - os: windows-latest
            qt-version: '6.2.0'
          - os: windows-latest
            qt-version: '6.4.2'
          - os: windows-latest
            qt-version: '6.5.0'
          - os: windows-latest
            qt-version: '6.6.0'
          - os: windows-latest
            qt-version: '6.10.1'

    steps:
    - uses: actions/checkout@v2

      #
      # Install Qt
      #

    # https://github.com/marketplace/actions/install-qt
    - if: contains( matrix.os, 'windows') && ( matrix.qt-version == '5.7' )
      name: Install Qt 5.7 on Windows
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.qt-version }}
        arch: win32_mingw53
        # try mirror
#        mirror: 'http://mirrors.ocf.berkeley.edu/qt/'
        cache: true
        aqtversion: '==0.9.4'
#        py7zrversion: '==0.9.0'
    - if: contains( matrix.os, 'windows') && ( matrix.qt-version == '5.15.2' )
      name: Install Qt 5.15.2 on Windows
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.qt-version }}
        arch: win64_mingw81
        cache: true
    - if: contains( matrix.os, 'windows') && ( matrix.qt-version != '5.7' ) && ( matrix.qt-version != '5.15.2' )
      name: Install Qt on Windows
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.qt-version }}
        arch: win64_mingw73
        cache: true
    - if: false == contains( matrix.os, 'windows') && !startsWith( matrix.qt-version, '6.' )
      name: Install Qt
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.qt-version }}
        cache: true
    - if: false == contains( matrix.os, 'windows') && startsWith( matrix.qt-version, '6.' )
      name: Install Qt
      uses: jurplel/install-qt-action@v4
      with:
        version: ${{ matrix.qt-version }}
        cache: true

      #
      # Build qmarkdowntextedit
      #

    - name: Build qmarkdowntextedit
      run: |
        qmake && make
