Skip to content

fix Windows CI job

fix Windows CI job #45

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
compiler: [msvc, gcc, clang]
qt_version: [qt5, qt6]
exclude:
- os: ubuntu-latest
compiler: msvc
- os: macos-latest
compiler: gcc
- os: macos-latest
compiler: msvc
- os: windows-latest
compiler: clang
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest
- if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
- name: Install Dependencies (Windows only)
if: runner.os == 'Windows'
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install pkgconfiglite
- name: Install Qt (Mac/Linux only)
if: runner.os != 'Windows'
run: |
if [ '${{ runner.os }}' == 'macOS' ]; then
if [ '${{ matrix.qt_version }}' == 'qt6' ]; then
brew install qt6 pkg-config
brew link qt6 --force
echo "$(brew --prefix qt6)/bin" >> $GITHUB_PATH
else
brew install qt5 pkg-config
brew link qt5 --force
echo "$(brew --prefix qt5)/bin" >> $GITHUB_PATH
fi
elif [ '${{ runner.os }}' == 'Linux' ]; then
sudo apt-get update
if [ '${{ matrix.qt_version }}' == 'qt6' ]; then
sudo apt-get install -y qt6-base-dev qtchooser qmake6 qt6-base-dev-tools qt6-tools-dev pkg-config libsecret-1-dev
else
sudo apt-get install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qttools5-dev pkg-config libsecret-1-dev
fi
fi
- name: Set AQT Version and Arch (Windows only)
if: runner.os == 'Windows'
id: set_qt_arch
shell: pwsh
run: |
$qtVer = "${{ matrix.qt_version == 'qt5' && '5.15.2' || '6.5.3' }}"
$qtArch = "${{ matrix.compiler == 'msvc' && 'msvc2019_64' ||
matrix.qt_version == 'qt5' && matrix.compiler == 'gcc' && 'mingw81' ||
matrix.qt_version == 'qt6' && matrix.compiler == 'gcc' && 'mingw' }}"
echo "QT_VER=$qtVer" >> $GITHUB_OUTPUT
echo "QT_ARCH=$qtArch" >> $GITHUB_OUTPUT
- name: Install Qt (Windows only)
if: runner.os == 'Windows'
uses: jurplel/install-qt-action@v4
with:
version: ${{ steps.set_qt_arch.outputs.QT_VER }}
arch: win64_${{ steps.set_qt_arch.outputs.QT_ARCH }}
dir: 'C:\'
cache: true
tools: 'tools_mingw1310'
- name: Setup Build Directory
run: |
mkdir -p ${{ github.workspace }}/work/build/${{ github.event.repository.name }}
- name: Run CMake (Windows only)
if: runner.os == 'Windows'
shell: pwsh
run: |
if ( '${{ matrix.compiler }}' -eq 'msvc' ) {
$generator = "NMake Makefiles"
} else {
$generator = "MinGW Makefiles"
}
if ( '${{ matrix.compiler }}' -eq 'gcc' ) {
echo "C:/Qt/Tools/mingw1310_64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:PATH = "C:\Qt\Tools\mingw1310_64\bin;$env:PATH"
}
cd "${{ github.workspace }}/work/build/${{ github.event.repository.name }}"
cmake -G $generator "${{ github.workspace }}" `
-DCMAKE_BUILD_TYPE=Release `
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" `
-DCMAKE_PREFIX_PATH=$env:QT_ROOT_DIR `
${{ matrix.qt_version == 'qt6' && '-DBUILD_WITH_QT6=true' || '' }}
- name: Run CMake (Mac/Linux Only)
if: runner.os != 'Windows'
run: |
cd ${{ github.workspace }}/work/build/${{ github.event.repository.name }}
cmake -G Ninja ${{ github.workspace }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" \
${{ matrix.qt_version == 'qt6' && '-DBUILD_WITH_QT6=true' || '' }}
- name: Build and Install
run: |
cd ${{ github.workspace }}/work/build/${{ github.event.repository.name }}
cmake --build .
cmake --install . --prefix "${{ github.workspace }}/install"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.qt_version }}
path: ${{ github.workspace }}/work/build/${{ github.event.repository.name }}