Skip to content

Professional-quality pass: harden the Kit, de-duplicate it into the examples, add CI #2

Professional-quality pass: harden the Kit, de-duplicate it into the examples, add CI

Professional-quality pass: harden the Kit, de-duplicate it into the examples, add CI #2

Workflow file for this run

name: build
# Builds the native box2dxt shared library and runs the C smoke test on Linux,
# macOS and Windows. On a version tag (v*) the per-OS binaries are attached to
# the matching GitHub Release — those are the canonical artifacts referenced by
# prebuilt/README.md. Pull requests get the same build + test gate (no release).
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
workflow_dispatch:
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
# Cheap gate: the examples embed a generated copy of the Kit; fail fast if it
# has drifted from the canonical src/box2dxt-kit.livecodescript.
embedded-kit:
name: embedded Kit in sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify examples embed the canonical Kit
run: python3 tools/sync-embedded-kit.py --check
build:
name: build & smoke-test (${{ matrix.name }})
needs: embedded-kit
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
# AVX2 off → SSE2 baseline, so the binary runs on any x86-64 CPU.
cmake_args: -DBOX2D_AVX2=OFF
lib: libbox2dxt.so
asset: libbox2dxt-linux-x86_64.so
- name: macos-universal
os: macos-latest
# Intel + Apple Silicon in one dylib; AVX2 off keeps the x86 slice portable.
# The arch list is quoted so bash does not split on the ';'.
cmake_args: '-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DBOX2D_AVX2=OFF'
lib: libbox2dxt.dylib
asset: libbox2dxt-macos-universal.dylib
- name: windows-x64
os: windows-latest
cmake_args: -DBOX2D_AVX2=OFF
lib: box2dxt.dll
asset: box2dxt-windows-x64.dll
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBOX2DXT_BUILD_TESTS=ON ${{ matrix.cmake_args }}
- name: Build
run: cmake --build build --config Release
- name: Smoke test
run: ctest --test-dir build --build-config Release --output-on-failure
- name: Stage library
shell: bash
run: |
mkdir -p dist
# MSVC drops the DLL in build/Release/; single-config generators use build/.
src="$(find build -maxdepth 2 -name '${{ matrix.lib }}' | head -n 1)"
test -n "$src" || { echo "could not find ${{ matrix.lib }} under build/"; exit 1; }
cp "$src" "dist/${{ matrix.asset }}"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: dist/${{ matrix.asset }}
if-no-files-found: error
# Tag builds only: gather the three binaries and attach them to the Release.
release:
name: attach binaries to the Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Upload to the Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" dist/* \
--repo "${GITHUB_REPOSITORY}" --title "${GITHUB_REF_NAME}" --generate-notes \
|| gh release upload "${GITHUB_REF_NAME}" dist/* --repo "${GITHUB_REPOSITORY}" --clobber