Files
cell/.github/workflows/build.yml

302 lines
9.8 KiB
YAML

name: Build
on:
push:
branches: [ "master" ]
pull_request:
jobs:
# ===============================================================
# LINUX BUILD
# ===============================================================
build-linux:
runs-on: ubuntu-latest
steps:
# 1) Check out code
- name: Check Out Code
uses: actions/checkout@v3
# 2) Install system dependencies + ccache
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libasound2-dev libpulse-dev libudev-dev \
libwayland-dev wayland-protocols libxkbcommon-dev \
libx11-dev libxext-dev libxrandr-dev libxcursor-dev \
libxi-dev libxinerama-dev libxss-dev \
libegl1-mesa-dev libgl1-mesa-dev \
cmake ninja-build git build-essential binutils mold meson pkg-config \
ccache
# 3) Configure ccache
- name: Configure ccache
run: |
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
# 4) Cache ccache
- name: Cache ccache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache-linux-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }}
restore-keys: |
ccache-linux-
# 5) Cache SDL3 (Linux)
- name: Cache SDL3 (Linux)
uses: actions/cache@v3
with:
path: |
sdl3
sdl3-build
key: sdl3-linux-${{ hashFiles('sdl3/CMakeLists.txt') }}
# 6) Build SDL3 (Linux)
- name: Build SDL3 (Linux)
run: |
if [ ! -d "sdl3/.git" ]; then
echo "Cloning SDL3 repository..."
git clone --depth 1 --branch release-3.2.4 https://github.com/libsdl-org/SDL.git sdl3
else
echo "SDL3 source is already present (possibly from cache)."
fi
mkdir -p sdl3-build
cd sdl3-build
cmake ../sdl3 -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3" \
-DSDL_SHARED=ON \
-DSDL_STATIC=OFF
ninja
ninja install
# 7) Build Prosperon (Linux)
- name: Build Prosperon (Linux)
run: |
export PKG_CONFIG_PATH="${PWD}/sdl3-build/installed_sdl3/lib/pkgconfig:$PKG_CONFIG_PATH"
meson setup build_dbg -Dbuildtype=release -Db_lto=true -Db_ndebug=true
meson compile -C build_dbg
# 8) Create minimal artifact folder (Linux)
- name: Create artifact folder (Linux)
run: |
mkdir _pack
cp build_dbg/prosperon _pack/
# Adjust wildcard if there's a versioned libSDL3. e.g. libSDL3-0.600.0.so
cp sdl3-build/installed_sdl3/lib/libSDL3.so _pack/
# 9) Upload artifact (Linux)
- name: Upload Artifact (Linux)
uses: actions/upload-artifact@v4
with:
name: prosperon-artifacts-linux
path: _pack
# ===============================================================
# MACOS BUILD (Using Homebrew SDL3)
# ===============================================================
build-macos:
runs-on: macos-latest
steps:
# 1) Check out code
- name: Check Out Code
uses: actions/checkout@v3
# 2) Install dependencies (SDL3 via Homebrew) + ccache
- name: Install Dependencies (macOS)
run: |
brew update
brew install sdl3 ccache ninja meson
# 3) Configure ccache
- name: Configure ccache
run: |
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
# 4) Cache ccache
- name: Cache ccache
uses: actions/cache@v3
with:
path: ~/Library/Caches/ccache
key: ccache-macos-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }}
restore-keys: |
ccache-macos-
# 5) Build Prosperon (macOS) linking against Homebrew's SDL3
- name: Build Prosperon (macOS)
run: |
# Ensure pkg-config can find Homebrew's SDL3 .pc files
export PKG_CONFIG_PATH="$(brew --prefix sdl3)/lib/pkgconfig:$PKG_CONFIG_PATH"
meson setup build_macos -Dbuildtype=release -Db_lto=true -Db_ndebug=true
meson compile -C build_macos
# 6) Copy SDL3 .dylib from Homebrew for packaging
- name: Copy SDL3 library for packaging
run: |
SDL3_PREFIX=$(brew --prefix sdl3)
mkdir -p sdl3-macos
# Copy all versions of the SDL3 dynamic library
cp -a "${SDL3_PREFIX}/lib/libSDL3*.dylib" sdl3-macos/ || echo "No .dylib found, ignoring"
# 7) Create minimal artifact folder (macOS)
- name: Create artifact folder (macOS)
run: |
mkdir _pack
cp build_macos/prosperon _pack/
cp sdl3-macos/libSDL3*.dylib _pack/ || echo "No .dylib found, ignoring"
# 8) Upload artifact (macOS)
- name: Upload Artifact (macOS)
uses: actions/upload-artifact@v4
with:
name: prosperon-artifacts-macos
path: _pack
# ===============================================================
# WINDOWS BUILD (Cross-compiling on Ubuntu)
# ===============================================================
build-windows:
runs-on: ubuntu-latest
steps:
# 1) Check out code
- name: Check Out Code
uses: actions/checkout@v3
# 2) Install dependencies (MinGW, etc.) + ccache
- name: Install Dependencies (Windows Cross)
run: |
sudo apt-get update
sudo apt-get install -y \
mingw-w64 cmake ninja-build git build-essential \
binutils pkg-config meson ccache
# 3) Configure ccache for cross-compiler
- name: Configure ccache
run: |
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
# 4) Cache ccache
- name: Cache ccache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache-win-${{ hashFiles('**/*.c', '**/*.cpp', '**/*.h', '**/CMakeLists.txt', '**/meson.build') }}
restore-keys: |
ccache-win-
# 5) Cache SDL3 (Windows cross)
- name: Cache SDL3 (Windows cross)
uses: actions/cache@v3
with:
path: |
sdl3-win
sdl3-build-win
key: sdl3-win-${{ hashFiles('sdl3-win/CMakeLists.txt') }}
# 6) Build SDL3 (Windows cross)
- name: Build SDL3 (Windows cross)
run: |
if [ ! -d "sdl3-win/.git" ]; then
echo "Cloning SDL3 for Windows cross..."
git clone --depth 1 --branch release-3.2.4 https://github.com/libsdl-org/SDL.git sdl3-win
else
echo "SDL3-win source already present (possibly from cache)."
fi
mkdir -p sdl3-build-win
cd sdl3-build-win
cmake ../sdl3-win -GNinja \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${PWD}/installed_sdl3_win" \
-DSDL_SHARED=ON \
-DSDL_STATIC=OFF
ninja
ninja install
# 7) Expose local SDL3 (Windows cross) for pkg-config
- name: Configure PKG_CONFIG_PATH (Windows cross)
run: |
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/sdl3-build-win/installed_sdl3_win/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
# 8) Build Prosperon (Windows cross)
- name: Build Prosperon (Windows cross)
run: |
meson setup -Dbuildtype=release -Db_lto=true -Db_ndebug=true --cross-file mingw32.cross build_win
meson compile -C build_win
# 9) Create minimal artifact folder (Windows)
- name: Create package folder
run: |
mkdir _pack
cp build_win/prosperon.exe _pack/
cp sdl3-build-win/installed_sdl3_win/bin/SDL3.dll _pack/
# 10) Upload artifacts (Windows cross)
- name: Upload Artifact (Windows cross)
uses: actions/upload-artifact@v4
with:
name: prosperon-artifacts-windows
path: _pack
package-dist:
# This job depends on the three builds completing successfully.
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: prosperon-artifacts-linux
path: linux_artifacts
- name: Download macOS Artifacts
uses: actions/download-artifact@v4
with:
name: prosperon-artifacts-macos
path: macos_artifacts
- name: Download Windows Artifacts
uses: actions/download-artifact@v4
with:
name: prosperon-artifacts-windows
path: windows_artifacts
- name: Create the Dist Folder
run: |
mkdir dist
cp README.md dist/
cp license.txt dist/
cp -r examples dist/
# Make subdirectories for each platform
mkdir dist/linux
mkdir dist/macos
mkdir dist/win
# -------------------
# Copy artifacts in
# -------------------
cp linux_artifacts/* dist/linux/
cp macos_artifacts/* dist/macos/
cp windows_artifacts/* dist/win/
- name: Upload Final Dist
uses: actions/upload-artifact@v4
with:
name: prosperon
path: dist