Skip to content

Cross Platform Build #51

Cross Platform Build

Cross Platform Build #51

name: Cross Platform Build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm ]
platform: [ linux, windows ]
c_compiler: [ gcc, clang, cl ]
build_type: [ Debug, Release ]
include:
- c_compiler: gcc
cpp_compiler: g++
- c_compiler: clang
cpp_compiler: clang++
- c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
architecture: x86-64
- os: ubuntu-24.04-arm
architecture: arm64
- os: windows-latest
architecture: x86-64
- os: windows-11-arm
architecture: arm64
exclude:
- platform: linux
os: windows-latest
- platform: linux
os: windows-11-arm
- platform: windows
os: ubuntu-latest
- platform: windows
os: ubuntu-24.04-arm
- platform: linux
c_compiler: cl
- platform: windows
c_compiler: gcc
- platform: windows
c_compiler: clang
steps:
- uses: actions/checkout@v4
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: ${{ steps.strings.outputs.build-output-dir }}/_deps
key: ${{ matrix.build_type }}-${{ matrix.c_compiler }}-deps-${{ hashFiles('**/.git/HEAD') }}
- name: Install Packages
if: ${{ matrix.platform == 'linux' }}
run: sudo apt-get update && sudo apt-get install -qq cmake gcc g++ clang git
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DLUNA_WARNINGS_ARE_FATAL=ON
-DLUNA_EXAMPLES=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Upload Compiled Binary
if: ${{ matrix.os == 'linux' }}
uses: actions/upload-artifact@v4.6.2
with:
name: libLuna_${{ matrix.architecture }}_${{ matrix.build_type }}_${{ matrix.c_compiler }}.a
path: build/libLuna.a
retention-days: 90
- name: Upload Compiled Binary
if: ${{ matrix.os == 'windows' }}
uses: actions/upload-artifact@v4.6.2
with:
name: Luna_${{ matrix.architecture }}_${{ matrix.build_type }}.lib
path: build/${{ matrix.build_type }}/Luna.lib
retention-days: 90