generated from ewpratten/rust-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (95 loc) · 2.98 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
name: Build
on:
pull_request:
push:
paths:
- ".github/workflows/build.yml"
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/src/*"
jobs:
build_and_test:
name: Build & Test
# Use a build matrix to run this job targeting all supported platforms
runs-on: ubuntu-latest
strategy:
matrix:
# All supported targets
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
# All supported Rust channels
rust_channel:
- stable
# Common build steps
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust_channel }}
override: true
# Builds targeting aarch64 require `aarch64-linux-gnu-strip`
- name: Install aarch64-linux-gnu-strip
if: matrix.target == 'aarch64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y binutils-aarch64-linux-gnu
- name: Install cargo-deb
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-deb
- name: Install cargo-generate-rpm
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-generate-rpm
- name: Compile
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Run Tests
uses: actions-rs/cargo@v1
with:
use-cross: true
command: test
args: --all --release --target ${{ matrix.target }}
- name: Package DEB
uses: actions-rs/cargo@v1
with:
use-cross: false
command: deb
args: --target ${{ matrix.target }} --no-build
- name: Package RPM
uses: actions-rs/cargo@v1
with:
use-cross: false
command: generate-rpm
args: --target ${{ matrix.target }}
- name: Upload DEB
uses: actions/upload-artifact@v3
with:
name: debian-packages
path: target/${{ matrix.target }}/debian/*.deb
- name: Upload RPM
uses: actions/upload-artifact@v3
with:
name: rpm-packages
path: target/${{ matrix.target }}/generate-rpm/*.rpm
- name: Determine binary sizes
id: get-bin-size-info
run: |
body="$(du -h target/${{ matrix.target }}/release/protomask{,-clat,-6over4} | sort -hr)"
delimiter="$(openssl rand -hex 8)"
echo "body<<$delimiter" >> $GITHUB_OUTPUT
echo "$body" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
- name: Add binary size info to commit
uses: peter-evans/commit-comment@v2
with:
body: |
## Binary sizes for `${{ matrix.target }}`
**Channel:** `${{ matrix.rust_channel }}`
```
${{ steps.get-bin-size-info.outputs.body }}
```