-
Notifications
You must be signed in to change notification settings - Fork 7
132 lines (130 loc) · 4.64 KB
/
action-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
name: Action Build
on:
workflow_dispatch:
workflow_call:
inputs:
name:
required: true
type: string
profile:
type: string
default: dev
channel:
type: string
default: stable
artifact:
type: boolean
default: true
jobs:
build:
strategy:
fail-fast: true
matrix:
include:
- os: windows-latest
rust-target: x86_64-pc-windows-msvc
platform: win32
arch: x64
libc: msvc
- os: windows-latest
rust-target: i686-pc-windows-msvc
platform: win32
arch: ia32
libc: msvc
- os: windows-latest
rust-target: aarch64-pc-windows-msvc
platform: win32
arch: arm64
libc: msvc
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
platform: linux
arch: x64
libc: glibc
- os: ubuntu-20.04
rust-target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
libc: glibc
- os: ubuntu-20.04
rust-target: arm-unknown-linux-gnueabihf
platform: linux
arch: armhf
libc: glibc
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-musl
platform: linux
arch: x64
libc: musl
- os: ubuntu-20.04
rust-target: aarch64-unknown-linux-musl
platform: linux
arch: arm64
libc: musl
- os: ubuntu-20.04
rust-target: arm-unknown-linux-musleabihf
platform: linux
arch: armhf
libc: musl
- os: macos-14
rust-target: x86_64-apple-darwin
platform: darwin
arch: x64
libc: system
- os: macos-14
rust-target: aarch64-apple-darwin
platform: darwin
arch: arm64
libc: system
name: Build for ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.libc }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchains
run: |
rustup set auto-self-update disable
rustup toolchain install ${{ inputs.channel }} -t ${{ matrix.rust-target }} --profile minimal
rustup default ${{ inputs.channel }}
rustup show
- name: Install AArch64 target toolchain for Linux
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
UPPER_TARGET=$(echo ${{ matrix.rust-target }} | tr '[a-z]-' '[A-Z]_')
echo "CARGO_TARGET_${UPPER_TARGET}_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
- name: Install ARM target toolchain for Linux
if: matrix.platform == 'linux' && matrix.arch == 'armhf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
UPPER_TARGET=$(echo ${{ matrix.rust-target }} | tr '[a-z]-' '[A-Z]_')
echo "CARGO_TARGET_${UPPER_TARGET}_LINKER=arm-linux-gnueabihf-gcc" >> "$GITHUB_ENV"
- name: Install musl toolchain for Linux
if: matrix.platform == 'linux' && matrix.libc == 'musl'
run: |
sudo apt-get update
sudo apt-get install musl-tools
- name: Cache cargo registry and index
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: |
cargo clean
cargo build --target ${{ matrix.rust-target }} --profile ${{ inputs.profile }} -vv
env:
RUSTFLAGS: ${{ fromJSON('["", "-C target-feature=+crt-static"]')[matrix.libc == 'msvc'] }}
- name: Move and rename binary
shell: bash
run: |
mv target/${{ matrix.rust-target }}/${{ inputs.profile == 'dev' && 'debug' || inputs.profile }}/${{ inputs.name }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }} ${{ inputs.name }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.libc }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.libc }}
path: ${{ inputs.name }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.libc }}${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}