-
Notifications
You must be signed in to change notification settings - Fork 49
178 lines (156 loc) · 5.56 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
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
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 }}
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
steps:
- uses: actions/checkout@v3
- name: Create `out/`
run: mkdir out
# Install Rust on the various platforms
- name: Install Rust for macOS
if: matrix.os == 'macos-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
- name: Install Rust for Windows
if: matrix.os == 'windows-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Windows GNU toolchain
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-gnu
- name: Install Linux musl toolchain
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
default: true
toolchain: stable
target: x86_64-unknown-linux-musl
- name: Install Linux musl toolchain for ARM64
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-musl
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
curl https://apt.llvm.org/llvm.sh | sudo bash -s 16
- name: Install Rust cache
uses: Swatinem/rust-cache@v2
- name: Lint code
uses: actions-rs/cargo@v1
with:
command: clippy
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
# Linux CIs don't have GUIs
args: --no-default-features
- name: Build macOS Intel
if: matrix.os == 'macos-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-apple-darwin --release
- name: Build macOS ARM
if: matrix.os == 'macos-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=aarch64-apple-darwin --release
- name: Zip macOS outputs
if: matrix.os == 'macos-latest'
run: |
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
- name: Build Windows MSVC
if: matrix.os == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-pc-windows-msvc --release
- name: Zip Windows output
if: matrix.os == 'windows-latest'
run: 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'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-unknown-linux-musl --release
- name: Build ARM Linux
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: rustc
args: --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
env:
CC_aarch64_unknown_linux_musl: clang-16
- name: Zip Linux outputs
if: matrix.os == 'ubuntu-latest'
run: |
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
zip -r out/ferium-linux-arm64.zip -j target/aarch64-unknown-linux-musl/release/ferium
- name: Build Linux nogui
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-unknown-linux-musl --release --no-default-features
- name: Build ARM Linux nogui
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: rustc
args: --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
env:
CC_aarch64_unknown_linux_musl: clang-16
- name: Zip Linux nogui outputs
if: matrix.os == 'ubuntu-latest'
run: |
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
zip -r out/ferium-linux-arm64-nogui.zip -j target/aarch64-unknown-linux-musl/release/ferium
- name: Build Windows GNU
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-pc-windows-gnu --release
- name: Zip Windows GNU output
if: matrix.os == 'ubuntu-latest'
run: 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@v3
with:
name: binaries
path: out/ferium*.zip
if-no-files-found: error