Create cmake-multi-platform.yml #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CMake Windows Build | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
env: | |
BUILD_TYPE: Release | |
jobs: | |
build-and-package-windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
include: | |
- compiler: mingw | |
artifact_extension: zip | |
mingw_version: 13.1.0 | |
- compiler: msvc | |
artifact_extension: zip | |
steps: | |
- uses: actions/checkout@v3 | |
# Cache MinGW installation to speed up repeated builds | |
- name: Cache MinGW Package | |
if: matrix.compiler == 'mingw' | |
uses: actions/cache@v3 | |
with: | |
path: C:\ProgramData\chocolatey\lib\mingw | |
key: mingw-${{ matrix.mingw_version }} | |
restore-keys: mingw- | |
# MinGW Setup with a 20-minute timeout for installation | |
- name: Install MinGW | |
if: matrix.compiler == 'mingw' | |
timeout-minutes: 20 | |
run: choco install mingw --version ${{ matrix.mingw_version }} | |
shell: cmd | |
- name: Set up MinGW environment variables | |
if: matrix.compiler == 'mingw' | |
run: | | |
echo "CC=gcc" >> $GITHUB_ENV | |
echo "CXX=g++" >> $GITHUB_ENV | |
# MSVC Setup | |
- name: Configure CMake for MSVC | |
if: matrix.compiler == 'msvc' | |
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_STANDARD=20 -A x64 | |
shell: pwsh | |
- name: Configure CMake for MinGW | |
if: matrix.compiler == 'mingw' | |
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=20 | |
shell: pwsh | |
# Build | |
- name: Build Project | |
run: cmake --build build --config ${{ env.BUILD_TYPE }} --verbose | |
shell: pwsh | |
# Test | |
- name: Run Tests | |
working-directory: build | |
run: ctest -C ${{ env.BUILD_TYPE }} | |
shell: pwsh | |
# Package | |
- name: Package the Build (Windows) | |
run: Compress-Archive -Path build/* -DestinationPath stargen.${{ matrix.artifact_extension }} | |
shell: pwsh | |
# Upload Artifact | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: stargen-${{ matrix.compiler }}.${{ matrix.artifact_extension }} | |
path: stargen.${{ matrix.artifact_extension }} |