-
Notifications
You must be signed in to change notification settings - Fork 48
122 lines (103 loc) · 4.08 KB
/
build.yml
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
name: Build
on:
push:
# Do not run on tag pushes
branches: '**'
# Only run when;
paths:
# any Rust code has changed,
- "**.rs"
# this workflow has changed,
- ".github/workflows/build.yml"
# dependencies have changed,
- "Cargo.lock"
# or a rebuild is manually called.
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Create `out/`
run: mkdir out
# Install Rust on the various platforms
- name: Install Rust for macOS
if: matrix.os == 'macos-latest'
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin, x86_64-apple-darwin
- name: Install Rust for Windows
if: matrix.os == 'windows-latest'
uses: dtolnay/rust-toolchain@stable
- name: Install Rust for Linux
if: matrix.os == 'ubuntu-latest'
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-gnu, x86_64-unknown-linux-musl, aarch64-unknown-linux-musl
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
curl https://apt.llvm.org/llvm.sh | sudo bash -s 17
- name: Install Rust cache
uses: Swatinem/rust-cache@v2
- name: Lint code
run: cargo clippy
- name: Run tests
run: cargo test --no-default-features
- name: Build macOS Intel
if: matrix.os == 'macos-latest'
run: |
cargo build --target=x86_64-apple-darwin --release
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
- name: Build macOS ARM
if: matrix.os == 'macos-latest'
run: |
cargo build --target=aarch64-apple-darwin --release
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
- name: Build Windows MSVC
if: matrix.os == 'windows-latest'
run: |
cargo build --target=x86_64-pc-windows-msvc --release
Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
- name: Build Linux
if: matrix.os == 'ubuntu-latest'
run: |
cargo build --target=x86_64-unknown-linux-musl --release
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
- name: Build ARM Linux
if: matrix.os == 'ubuntu-latest'
run: |
cargo rustc --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
zip -r out/ferium-linux-arm64.zip -j target/aarch64-unknown-linux-musl/release/ferium
env:
CC_aarch64_unknown_linux_musl: clang-17
- name: Build Linux nogui
if: matrix.os == 'ubuntu-latest'
run: |
cargo build --target=x86_64-unknown-linux-musl --release --no-default-features
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
- name: Build ARM Linux nogui
if: matrix.os == 'ubuntu-latest'
run: |
cargo rustc --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
zip -r out/ferium-linux-arm64-nogui.zip -j target/aarch64-unknown-linux-musl/release/ferium
env:
CC_aarch64_unknown_linux_musl: clang-17
- name: Build Windows GNU
if: matrix.os == 'ubuntu-latest'
run: |
cargo build --target=x86_64-pc-windows-gnu --release
zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
- name: Upload build artefacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.os }}
path: out/ferium*.zip
if-no-files-found: error