🔨 Add conan detection for github cmake action #4
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 | |
- os: ubuntu-latest | |
cpp_compiler: g++ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install conan cmake ninja | |
- name: Setup Conan | |
run: | | |
conan profile detect --force | |
- 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: | | |
echo "build-output-dir=${{ github.workspace }}/build/${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" | |
- name: Configure CMake | |
shell: bash | |
run: | | |
preset="conan-release" | |
if [ "${{ matrix.build_type }}" = "RelWithDebInfo" ]; then | |
preset="conan-relwithdebinfo" | |
fi | |
cmake --preset $preset \ | |
-S . \ | |
-B ${{ steps.strings.outputs.build-output-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 }}/src/game/stabby* | |
${{ steps.strings.outputs.build-output-dir }}/src/game/stabby.exe | |
if-no-files-found: ignore |