Skip to content

Add 32-bit Windows and Linux builds to CI #10

Add 32-bit Windows and Linux builds to CI

Add 32-bit Windows and Linux builds to CI #10

Workflow file for this run

name: Build
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- 'LICENSE'
- 'examples/**'
- '.gitignore'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- 'examples/**'
- '.gitignore'
workflow_dispatch:
# Cancel older in-flight runs on the same ref — no point burning minutes
# on a commit that's already been superseded.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
env:
# Disable incremental compilation in CI — it bloats the cache and
# doesn't help when Swatinem/rust-cache is restoring a warm target/
# tree (the recommended setting from rust-cache's README).
CARGO_INCREMENTAL: "0"
strategy:
fail-fast: false
matrix:
include:
- label: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
final: gmcl_buttplug_win64.dll
- label: windows-x86
os: windows-latest
target: i686-pc-windows-msvc
final: gmcl_buttplug_win32.dll
- label: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
final: gmcl_buttplug_linux64.dll
- label: linux-x86
os: ubuntu-latest
target: i686-unknown-linux-gnu
final: gmcl_buttplug_linux.dll
- label: macos-x86_64
os: macos-15-intel # Intel runner — matches GMod's x86_64 macOS build
target: x86_64-apple-darwin
final: gmcl_buttplug_osx64.dll
steps:
- uses: actions/checkout@v6.0.2
- name: Install Linux system dependencies
if: runner.os == 'Linux'
# i686 cross-compile on an x86_64 Ubuntu runner needs multilib and
# the i386 variants of the dev libs. We also whitelist cross-arch
# queries in pkg-config and point it at the i386 .pc files, so the
# btleplug/serialport build scripts find dbus and udev.
run: |
if [ "${{ matrix.target }}" = "i686-unknown-linux-gnu" ]; then
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib libdbus-1-dev:i386 libudev-dev:i386 pkg-config
echo "PKG_CONFIG_ALLOW_CROSS=1" >> "$GITHUB_ENV"
echo "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig" >> "$GITHUB_ENV"
else
sudo apt-get update
sudo apt-get install -y libdbus-1-dev libudev-dev pkg-config
fi
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- name: Cargo cache
uses: Swatinem/rust-cache@v2.9.1
with:
key: ${{ matrix.target }}
# Only write the cache from main — PR/feature-branch builds still
# read the main cache but don't churn it with their own entries.
# GitHub's 10GB per-repo quota evicts LRU, so keeping writes
# centralized makes the cache much more effective.
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build (release)
# `cargo xtask build` compiles the cdylib AND writes the GMod-named
# artifact (gmcl_buttplug_<platform>.dll) alongside it in one step.
run: cargo xtask build --target ${{ matrix.target }}
- name: Upload binary
uses: actions/upload-artifact@v7.0.1
with:
name: ${{ matrix.final }}
path: target/${{ matrix.target }}/release/${{ matrix.final }}
if-no-files-found: error