name: Windows build

on:
  push:
    branches: [ master, develop, 1.0.* ]
    tags: 1.0.*
    
  pull_request:
    branches: [ master, develop, 1.0.* ]

jobs:
  build:
    runs-on: windows-latest

    strategy:
      matrix:
        qt: ['6.x'] 
    
    defaults:
      run:
       shell: msys2 {0}

    steps:
    - uses: actions/checkout@v2
     
    - uses: msys2/setup-msys2@v2
      with:
        msystem: MINGW64
        update: true
        install: base-devel mingw-w64-x86_64-make mingw-w64-x86_64-clang mingw-w64-x86_64-postgresql mingw-w64-x86_64-qt6
                     
    # Workaround: Instead of using $GITHUB_WORKSPACE in PREFIX we actually use the path converted to unix-like
    # since we're running the building inside msys2
    - name: Running qmake
      run: |
        cd $GITHUB_WORKSPACE;
        qmake-qt6 pgmodeler.pro -spec win32-clang-g++ -r PREFIX=D:/a/pgmodeler/pgmodeler/build \
          XML_INC=$(cygpath -m /mingw64/include/libxml2) \
          XML_LIB=$(cygpath -m /mingw64/bin/libxml2-2.dll) \
          PGSQL_INC=$(cygpath -m /mingw64/include) \
          PGSQL_LIB=$(cygpath -m /mingw64/bin/libpq.dll) \
          CONFIG+=debug

    - name: Building pgModeler
      run: mingw32-make -j6
     
    - name: Deploying pgModeler
      run: mingw32-make install
