mirror of
https://gitlab.com/raylibtemplates/rt.git
synced 2026-06-05 02:00:54 -04:00
140 lines
4.2 KiB
YAML
140 lines
4.2 KiB
YAML
name: CMake on multiple platforms
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: windows-latest
|
|
c_compiler: cl
|
|
cpp_compiler: cl
|
|
platform: Windows
|
|
artifact_name: windows
|
|
build_type: Release
|
|
|
|
- os: ubuntu-latest
|
|
c_compiler: gcc
|
|
cpp_compiler: g++
|
|
platform: Linux
|
|
artifact_name: linux
|
|
build_type: Release
|
|
|
|
- os: macos-latest
|
|
c_compiler: clang
|
|
cpp_compiler: clang++
|
|
platform: MacOS
|
|
artifact_name: macos
|
|
build_type: Release
|
|
|
|
- os: ubuntu-latest
|
|
c_compiler: emcc
|
|
cpp_compiler: em++
|
|
platform: Web
|
|
artifact_name: web
|
|
build_type: Release
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set reusable strings
|
|
id: strings
|
|
shell: bash
|
|
run: |
|
|
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Install Linux Dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev vim-common
|
|
|
|
- name: Install MacOS Dependencies
|
|
if: runner.os == 'macOS'
|
|
run: |
|
|
brew install cmake
|
|
xcode-select --install || true
|
|
|
|
- name: Install Windows Dependencies
|
|
if: runner.os == 'Windows'
|
|
run: choco install vim -y
|
|
shell: pwsh
|
|
|
|
- name: Cache CMake files
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cmake
|
|
${{ github.workspace }}/build/_deps
|
|
key: ${{ runner.os }}-cmake-${{ matrix.c_compiler }}-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-cmake-${{ matrix.c_compiler }}-
|
|
${{ runner.os }}-cmake-
|
|
|
|
- name: Setup Emscripten
|
|
if: matrix.c_compiler == 'emcc'
|
|
uses: mymindstorm/setup-emsdk@v14
|
|
with:
|
|
version: 3.1.45
|
|
|
|
- name: Setup Web Build Environment
|
|
if: matrix.c_compiler == 'emcc'
|
|
run: |
|
|
mkdir -p ${{ steps.strings.outputs.build-output-dir }}/assets
|
|
# cp -r assets/* ${{ steps.strings.outputs.build-output-dir }}/assets/
|
|
|
|
- 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 }}
|
|
${{ matrix.c_compiler == 'emcc' && '-DPLATFORM=Web -DCMAKE_EXE_LINKER_FLAGS="-s USE_GLFW=3 -s ASYNCIFY -s TOTAL_MEMORY=67108864 -s FORCE_FILESYSTEM=1 --preload-file assets --shell-file ../src/shell.html"' || '' }}
|
|
-S ${{ github.workspace }}
|
|
|
|
- name: Build
|
|
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
|
|
|
|
- name: Test
|
|
working-directory: ${{ steps.strings.outputs.build-output-dir }}
|
|
run: ctest --build-config ${{ matrix.build_type }}
|
|
|
|
- name: Create Release ZIP (Windows)
|
|
if: matrix.platform == 'Windows'
|
|
run: |
|
|
cd build/${{ matrix.build_type }}
|
|
Compress-Archive -Path *.exe -DestinationPath ../../${{ matrix.artifact_name }}.zip
|
|
shell: pwsh
|
|
|
|
- name: Create Release ZIP (Web)
|
|
if: matrix.platform == 'Web'
|
|
run: |
|
|
cd build
|
|
zip -r ../${{ matrix.artifact_name }}.zip *.html *.js *.data *.wasm
|
|
shell: bash
|
|
|
|
- name: Create Release ZIP (Linux/macOS)
|
|
if: matrix.platform == 'Linux' || matrix.platform == 'MacOS'
|
|
run: |
|
|
cd build
|
|
# Find executable files (not libraries or scripts) and zip them
|
|
find . -maxdepth 1 -type f -executable ! -name "*.so" ! -name "*.a" ! -name "*.sh" -exec zip ../${{ matrix.artifact_name }}.zip {} +
|
|
shell: bash
|
|
|
|
- name: Upload Build Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.artifact_name }}
|
|
path: ${{ matrix.artifact_name }}.zip
|