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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.lib_dir }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
lib_name: libalice_physics.dylib
static_lib_name: libalice_physics.a
lib_dir: macOS
# macos-*-intel labels are GitHub's Intel-native macOS runners.
# Regular macos-14 / macos-15 / macos-26 are Apple Silicon (ARM) —
# building x86_64-apple-darwin from ARM requires either a cross
# toolchain or native Intel hardware. `macos-15-intel` keeps this
# build natively linked without cross-compilation setup.
- os: macos-15-intel
target: x86_64-apple-darwin
lib_name: libalice_physics.dylib
static_lib_name: libalice_physics.a
lib_dir: macOS-Intel
- os: windows-latest
target: x86_64-pc-windows-msvc
lib_name: alice_physics.dll
static_lib_name: alice_physics.lib
lib_dir: Win64
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
lib_name: libalice_physics.so
static_lib_name: libalice_physics.a
lib_dir: Linux
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build release (dynamic library)
shell: bash
run: |
cargo rustc --release --features "ffi" --target ${{ matrix.target }} \
--crate-type cdylib
- name: Build release (static library)
shell: bash
run: |
cargo rustc --release --features "ffi" --target ${{ matrix.target }} \
--crate-type staticlib
- name: Package UE5 Plugin
shell: bash
run: |
PLUGIN_DIR="AlicePhysics"
mkdir -p "$PLUGIN_DIR/ThirdParty/AlicePhysics/lib/${{ matrix.lib_dir }}"
mkdir -p "$PLUGIN_DIR/ThirdParty/AlicePhysics/include"
cp unreal-plugin/AlicePhysics.uplugin "$PLUGIN_DIR/"
cp -r unreal-plugin/Source "$PLUGIN_DIR/"
cp -r unreal-plugin/Resources "$PLUGIN_DIR/" 2>/dev/null || true
cp unreal-plugin/README.md "$PLUGIN_DIR/"
cp include/alice_physics.h "$PLUGIN_DIR/ThirdParty/AlicePhysics/include/"
cp "target/${{ matrix.target }}/release/${{ matrix.lib_name }}" \
"$PLUGIN_DIR/ThirdParty/AlicePhysics/lib/${{ matrix.lib_dir }}/"
- name: Create UE5 ZIP (Unix)
if: runner.os != 'Windows'
run: zip -r "AlicePhysics-UE5-${{ matrix.lib_dir }}.zip" AlicePhysics/
- name: Create UE5 ZIP (Windows)
if: runner.os == 'Windows'
run: 7z a "AlicePhysics-UE5-${{ matrix.lib_dir }}.zip" AlicePhysics/
- name: Package Unity Plugin
shell: bash
run: |
UNITY_DIR="AlicePhysics-Unity"
mkdir -p "$UNITY_DIR/Plugins/${{ matrix.lib_dir }}"
cp bindings/AlicePhysics.cs "$UNITY_DIR/"
cp include/alice_physics.h "$UNITY_DIR/"
cp "target/${{ matrix.target }}/release/${{ matrix.lib_name }}" \
"$UNITY_DIR/Plugins/${{ matrix.lib_dir }}/"
- name: Create Unity ZIP (Unix)
if: runner.os != 'Windows'
run: zip -r "AlicePhysics-Unity-${{ matrix.lib_dir }}.zip" AlicePhysics-Unity/
- name: Create Unity ZIP (Windows)
if: runner.os == 'Windows'
run: 7z a "AlicePhysics-Unity-${{ matrix.lib_dir }}.zip" AlicePhysics-Unity/
- name: Package Static Library
shell: bash
run: |
STATIC_DIR="AlicePhysics-StaticLib-${{ matrix.lib_dir }}"
mkdir -p "$STATIC_DIR/lib"
mkdir -p "$STATIC_DIR/include"
cp include/alice_physics.h "$STATIC_DIR/include/"
cp "target/${{ matrix.target }}/release/${{ matrix.static_lib_name }}" \
"$STATIC_DIR/lib/"
- name: Create Static Library ZIP (Unix)
if: runner.os != 'Windows'
run: zip -r "AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip" "AlicePhysics-StaticLib-${{ matrix.lib_dir }}/"
- name: Create Static Library ZIP (Windows)
if: runner.os == 'Windows'
run: 7z a "AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip" "AlicePhysics-StaticLib-${{ matrix.lib_dir }}/"
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: release-${{ matrix.lib_dir }}
path: |
AlicePhysics-UE5-${{ matrix.lib_dir }}.zip
AlicePhysics-Unity-${{ matrix.lib_dir }}.zip
AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip
python-wheel:
name: Python Wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install maturin
run: pip install maturin
- name: Build wheel
run: maturin build --release --features python --out dist/
# the wheel itself is installed and exercised, not only built: a wheel that
# builds but fails to import or returns wrong values must not be released
- name: Install the wheel and run the binding tests
shell: bash
run: |
python -m pip install numpy dist/*.whl
python python/tests/test_binding.py
- name: Upload wheel
uses: actions/upload-artifact@v6
with:
name: wheel-${{ matrix.os }}
path: dist/*.whl
release:
name: Create Release
needs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
files: |
artifacts/**/*.zip
artifacts/**/*.whl
generate_release_notes: true