🔨 Another CMake github actions attempt #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: Build and Test | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
build_type: [Release, RelWithDebInfo] | |
include: | |
- os: windows-latest | |
cpp_compiler: cl | |
separator: '\\' | |
- os: ubuntu-latest | |
cpp_compiler: g++ | |
separator: "/" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install System Dependencies (Ubuntu) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libegl1-mesa-dev libgl1-mesa-dev | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install conan cmake ninja | |
- name: Setup Conan | |
shell: bash | |
run: | | |
conan profile detect --force | |
# Add system package manager settings to detected profile | |
echo "[conf]" >> ~/.conan2/profiles/default | |
echo "tools.system.package_manager:mode=install" >> ~/.conan2/profiles/default | |
echo "tools.system.package_manager:sudo=True" >> ~/.conan2/profiles/default | |
- name: Cache Conan packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.conan2 | |
key: ${{ runner.os }}-conan-${{ hashFiles('**/conanfile.txt') }} | |
restore-keys: | | |
${{ runner.os }}-conan- | |
- name: Install Conan Dependencies | |
run: | | |
conan install . --build=missing -s build_type=${{ matrix.build_type }} | |
- name: Set Build Directory | |
id: strings | |
shell: bash | |
run: | | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
echo "build-output-dir=${{ github.workspace }}\\build\\${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" | |
echo "game-path=src\\game\\stabby.exe" >> "$GITHUB_OUTPUT" | |
else | |
echo "build-output-dir=${{ github.workspace }}/build/${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" | |
echo "game-path=src/game/stabby" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Configure CMake | |
shell: bash | |
run: | | |
preset="conan-release" | |
if [ "${{ matrix.build_type }}" = "RelWithDebInfo" ]; then | |
preset="conan-relwithdebinfo" | |
fi | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
build_dir="${{ github.workspace }}\\build\\${{ matrix.build_type }}" | |
else | |
build_dir="${{ github.workspace }}/build/${{ matrix.build_type }}" | |
fi | |
cmake --preset $preset \ | |
-S . \ | |
-B "$build_dir" \ | |
-G Ninja \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
- name: Build | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} | |
- name: Test | |
working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
run: ctest --build-config ${{ matrix.build_type }} | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ runner.os }}-${{ matrix.build_type }}-build | |
path: ${{ steps.strings.outputs.build-output-dir }}/${{ steps.strings.outputs.game-path }} | |
if-no-files-found: ignore |