-
Notifications
You must be signed in to change notification settings - Fork 3
186 lines (147 loc) · 5.01 KB
/
compile.yaml
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
179
180
181
182
183
184
185
186
on:
push:
branches: [ main ]
tags: [ "v*" ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
name: Compile
jobs:
build-macos:
name: Build for macOS ${{ matrix.arch }}
runs-on: ubuntu-22.04
env:
SDKROOT: /opt/MacOSX11.3.sdk
strategy:
fail-fast: false
matrix:
arch:
- aarch64
- x86_64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install stable
rustup default stable
rustup target add ${{ matrix.arch }}-apple-darwin
- name: Setup Rust build cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.arch }}-macos
- name: Install zig and cargo-zigbuild
run: pip3 install ziglang cargo-zigbuild
- name: Download the macOS SDK
run: curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
- name: Build the binary
run: cargo zigbuild --release --target=${{ matrix.arch }}-apple-darwin -p z33-cli
- name: Create the archive
run: tar -czvf z33-cli-${{ matrix.arch }}-macos.tar.gz --owner=0 --group=0 -C target/${{ matrix.arch }}-apple-darwin/release/ z33-cli
- name: Upload the binary as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch }}-macos
path: z33-cli-${{ matrix.arch }}-macos.tar.gz
build-linux:
name: Build for Linux ${{ matrix.arch }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch:
- aarch64
- x86_64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install stable
rustup default stable
rustup target add ${{ matrix.arch }}-unknown-linux-musl
- name: Setup Rust build cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.arch }}-linux
- name: Install zig and cargo-zigbuild
run: pip3 install ziglang cargo-zigbuild
- name: Build the binary
run: cargo zigbuild --release --target=${{ matrix.arch }}-unknown-linux-musl -p z33-cli
- name: Create the archive
run: tar -czvf z33-cli-${{ matrix.arch }}-linux.tar.gz --owner=0 --group=0 -C target/${{ matrix.arch }}-unknown-linux-musl/release/ z33-cli
- name: Upload the binary as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch }}-linux
path: z33-cli-${{ matrix.arch }}-linux.tar.gz
build-windows:
name: Build for Windows ${{ matrix.arch }}
runs-on: ubuntu-22.04
env:
XWIN_ARCH: ${{ matrix.arch }}
XWIN_VARIANT: onecore
XWIN_CACHE_DIR: ./cargo-xwin
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- aarch64
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install stable
rustup default stable
rustup target add ${{ matrix.arch }}-pc-windows-msvc
- name: Setup Rust build cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.arch }}-pc-windows-msvc
- name: Setup cargo-xwin cache
uses: actions/cache@v3
with:
path: cargo-xwin
key: cargo-xwin-${{ matrix.arch }}
- name: Install cargo-xwin
run: pip3 install cargo-xwin
- name: Build the binary
run: cargo xwin build --release --target=${{ matrix.arch }}-pc-windows-msvc -p z33-cli
- name: Move the binary
run: mv target/${{ matrix.arch }}-pc-windows-msvc/release/z33-cli.exe ./z33-cli-${{ matrix.arch }}-windows.exe
- name: Upload the binary as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch }}-windows
path: z33-cli-${{ matrix.arch }}-windows.exe
publish:
name: Publish a release
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download the artifacts from the previous job
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Move the release assets
run: |
mv ./artifacts/{x86_64,aarch64}-{linux,macos,windows}/* ./
- name: Prepare a release
uses: softprops/action-gh-release@v1
with:
files: |
z33-cli-x86_64-linux.tar.gz
z33-cli-aarch64-linux.tar.gz
z33-cli-x86_64-macos.tar.gz
z33-cli-aarch64-macos.tar.gz
z33-cli-x86_64-windows.exe
z33-cli-aarch64-windows.exe
draft: true