name: Build platform (reusable) on: workflow_call: inputs: platform: description: "win-amd64 | linux-amd64 | linux-arm64" required: true type: string ref: description: "Git ref (SHA or tag) to check out and build" required: true type: string publish_mode: description: "'release' to upload as a GitHub release asset, 'artifact' to upload as a workflow artifact" required: true type: string artifact_name: description: "Artifact name when publish_mode is 'artifact'" required: false type: string default: "" outputs: version: description: "Derived build version string (REXGLUE_VERSION_STRING)" value: ${{ jobs.build.outputs.version }} jobs: build: runs-on: ${{ fromJSON('{"win-amd64":"windows-latest","linux-amd64":"ubuntu-latest","linux-arm64":"ubuntu-24.04-arm"}')[inputs.platform] }} outputs: version: ${{ steps.version.outputs.v }} steps: - uses: actions/checkout@v6 with: ref: ${{ inputs.ref }} submodules: recursive fetch-depth: 0 fetch-tags: true - name: Install toolchain (Windows) if: inputs.platform == 'win-amd64' run: choco install llvm cmake ninja -y - name: Install clang 20 (Linux) if: inputs.platform != 'win-amd64' run: | sudo apt-get update sudo apt-get install -y wget gnupg lsb-release wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 20 sudo apt-get install -y clang-20 lld-20 sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 200 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 200 - name: Install build deps (linux-amd64) if: inputs.platform == 'linux-amd64' run: | wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-noble.list http://packages.lunarg.com/vulkan/lunarg-vulkan-noble.list sudo apt update sudo apt install -y cmake ninja-build build-essential git curl unzip autoconf python3.12-venv \ libgtk-3-dev libx11-xcb-dev wine vulkan-sdk \ libasound2-dev libpulse-dev libpipewire-0.3-dev - name: Install build deps (linux-arm64) if: inputs.platform == 'linux-arm64' run: | sudo apt update sudo apt install -y cmake ninja-build build-essential git curl unzip autoconf python3.12-venv \ libgtk-3-dev libx11-xcb-dev libvulkan-dev glslc glslang-tools \ libasound2-dev libpulse-dev libpipewire-0.3-dev - name: Set up sccache uses: hendrikmuhs/ccache-action@v1.2.22 with: variant: sccache key: ${{ inputs.platform }} - name: Configure env: CC: ${{ inputs.platform == 'win-amd64' && '' || 'clang-20' }} CXX: ${{ inputs.platform == 'win-amd64' && '' || 'clang++-20' }} run: cmake --preset ${{ inputs.platform }} -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache - name: Build and install run: cmake --build out/build/${{ inputs.platform }} --target install --parallel - name: sccache stats if: always() shell: bash run: sccache --show-stats || true - name: Read version id: version shell: bash run: | v=$(sed -nE 's/^#define REXGLUE_VERSION_STRING "([^"]+)".*/\1/p' \ out/build/${{ inputs.platform }}/include/rex/version.h) echo "v=${v}" >> "$GITHUB_OUTPUT" - name: Package (Windows) if: inputs.platform == 'win-amd64' shell: bash run: | cd out/install 7z a "rexglue-sdk-${{ steps.version.outputs.v }}-${{ inputs.platform }}.zip" ${{ inputs.platform }} - name: Package (Linux) if: inputs.platform != 'win-amd64' run: | cd out/install zip -r "rexglue-sdk-${{ steps.version.outputs.v }}-${{ inputs.platform }}.zip" ${{ inputs.platform }} - name: Upload as release asset if: inputs.publish_mode == 'release' uses: softprops/action-gh-release@v2 with: files: out/install/rexglue-sdk-*-${{ inputs.platform }}.zip generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload as workflow artifact if: inputs.publish_mode == 'artifact' uses: actions/upload-artifact@v6 with: name: ${{ inputs.artifact_name }} path: out/install/rexglue-sdk-*-${{ inputs.platform }}.zip retention-days: 14