Files
SmokeAPI/.github/workflows/kb-build.yml
acidicoala bdbd1ff540 Updated CI
2025-10-05 23:10:37 +05:00

80 lines
2.6 KiB
YAML

name: Build
on:
workflow_call:
inputs:
module:
description: 'Module to be used in CMake config'
required: true
type: string
os:
description: '"Windows" or "Linux"'
required: true
type: string
bitness:
description: '32 or 64'
required: true
type: number
jobs:
build:
name: 🏗️ Build
runs-on: ${{ inputs.os == 'Linux' && 'ubuntu-24.04' || 'windows-2025'}}
container: ${{ inputs.os == 'Linux' && 'ghcr.io/acidicoala/koalabox:master' || '' }}
env:
BUILD_DIR: ${{ github.workspace }}/build
C_COMPILER: ${{ inputs.os == 'Linux' && 'clang' || 'cl' }}
CXX_COMPILER: ${{ inputs.os == 'Linux' && 'clang++' || 'cl' }}
OUTPUT_PATH: ${{ inputs.os == 'Linux' && '*.so' || 'Release/*.dll' }}
WIN_FLAGS: ${{ inputs.os == 'Windows' && inputs.bitness == 32 && '-A=Win32' || '' }}
LINUX_FLAGS: ${{ inputs.os == 'Linux' && inputs.bitness == 32 && '-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32' || '' }}
steps:
# Fix dubious ownership errors in docker container
- name: '✔️ Mark GitHub workspace as safe'
if: ${{ inputs.os == 'Linux' }}
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: '🛠️ Check compiler versions'
if: ${{ inputs.os == 'Linux' }}
run: |
clang++ --version
g++ --version
- name: '📥 Check out repository code'
uses: actions/checkout@v5
with:
submodules: recursive
- name: '🗃️ Cache CPM dependencies'
uses: actions/cache@v4
with:
key: ${{ inputs.os }}-CPM-cache
path: '${{ env.BUILD_DIR }}/.cache'
- name: '⚙️ Generate build files'
# Note: indenting arguments will lead to parsing errors
run: >
cmake
-B "${{ env.BUILD_DIR }}"
-DMODULE=${{ github.event.inputs.module }}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=${{ env.C_COMPILER }}
-DCMAKE_CXX_COMPILER=${{ env.CXX_COMPILER }}
${{ env.WIN_FLAGS }}
${{ env.LINUX_FLAGS }}
--debug-output
- name: '🏗️ Build ${{ inputs.module }}'
run: >
cmake
--build ${{ env.BUILD_DIR }}
--config Release
--target ${{ inputs.module }}
- name: '📤 Upload binaries'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.module }}-${{ inputs.os }}-${{ inputs.bitness }}
path: ${{ env.BUILD_DIR }}/${{ env.OUTPUT_PATH }}