Skip to content

Commit 31961d8

Browse files
committed
ci: add cross-platform build matrix workflow
1 parent 153adf1 commit 31961d8

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
name: Build (matrix)
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
target: x86_64-unknown-linux-gnu
20+
- os: ubuntu-latest
21+
target: aarch64-unknown-linux-gnu
22+
- os: macos-latest
23+
target: aarch64-apple-darwin
24+
- os: macos-13 # Intel mac
25+
target: x86_64-apple-darwin
26+
- os: windows-latest
27+
target: x86_64-pc-windows-msvc
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@stable
32+
with:
33+
targets: ${{ matrix.target }}
34+
- name: Cache cargo
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.cargo/registry
39+
~/.cargo/git
40+
target
41+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
42+
- name: Install cross deps (Linux aarch64)
43+
if: matrix.target == 'aarch64-unknown-linux-gnu'
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y gcc-aarch64-linux-gnu
47+
mkdir -p .cargo
48+
echo '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
49+
- name: Build
50+
run: cargo build --release --target ${{ matrix.target }}
51+
- name: Upload artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: cotengra-${{ matrix.target }}
55+
path: target/${{ matrix.target }}/release/*cotengra*.*
56+
57+
universal-macos:
58+
name: Create universal macOS dylib
59+
needs: build
60+
runs-on: macos-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Download macOS artifacts
64+
uses: actions/download-artifact@v4
65+
with:
66+
path: artifacts
67+
- name: Create universal binary
68+
run: |
69+
mkdir -p dist
70+
LIPO_INPUTS="$(find artifacts -name 'libcotengra.dylib' -maxdepth 4)"
71+
echo "Inputs: $LIPO_INPUTS"
72+
lipo -create $LIPO_INPUTS -output dist/libcotengra_universal.dylib
73+
- name: Upload universal binary
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: cotengra-macos-universal
77+
path: dist/libcotengra_universal.dylib
78+
79+
publish:
80+
name: Publish (manual)
81+
if: github.event_name == 'workflow_dispatch'
82+
needs: [build]
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- name: Download artifacts
87+
uses: actions/download-artifact@v4
88+
with:
89+
path: dist
90+
- name: List artifacts
91+
run: ls -R dist
92+

0 commit comments

Comments
 (0)