-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (119 loc) · 4.42 KB
/
build.yml
File metadata and controls
133 lines (119 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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:
test:
name: Tests
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: "0"
steps:
- uses: actions/checkout@v6.0.2
- name: Install Linux system dependencies
# Same deps as the x86_64 build leg — buttplug still has to link
# against libdbus/libudev even when we're only running pure-Rust
# unit tests.
run: |
sudo apt-get update
sudo apt-get install -y libdbus-1-dev libudev-dev pkg-config
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Cargo cache
uses: Swatinem/rust-cache@v2.9.1
with:
key: test-x86_64-unknown-linux-gnu
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run tests
run: cargo test --workspace --no-fail-fast
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