Repository navigation
286 lines (276 loc) · 9.3 KB
/
Copy pathbuild.yml
File metadata and controls
286 lines (276 loc) · 9.3 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: build
on:
push:
tags: ["v*"]
pull_request:
branches: ["main"]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
lint-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check licenses
test:
needs: lint-audit
name: cargo test (unit + integration)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: test-ubuntu
- name: Check formatting
run: cargo fmt --check
- name: Lint with clippy
run: cargo clippy --all-targets -- -D warnings
- name: Run unit tests
run: cargo test --lib
- name: Run integration tests
run: cargo test --test bypass --test dns --test encrypted_tunnel --test plain_tunnel --test rotation
linux-gnu:
needs: [lint-audit, test]
name: Build Linux (GNU)
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64
target_triple: x86_64-unknown-linux-gnu
apt_packages: ""
custom_env:
RUSTFLAGS: -C target-cpu=x86-64-v3
- target: arm64
target_triple: aarch64-unknown-linux-gnu
apt_packages: crossbuild-essential-arm64
custom_env:
CFLAGS_aarch64_unknown_linux_gnu: -D__ARM_ARCH=8
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-g++
RUSTC_LINKER: aarch64-linux-gnu-g++
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target_triple }}
- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake perl pkg-config libclang-dev
- name: Install target dependencies
if: ${{ matrix.apt_packages != '' }}
run: sudo apt-get install -y ${{ matrix.apt_packages }}
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Build
env: ${{ matrix.custom_env }}
run: cargo build --release --target ${{ matrix.target_triple }}
- name: Archive
run: |
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-linux-${{ matrix.target }}
path: dist/
linux-musl:
needs: [lint-audit, test]
name: Build Linux (musl)
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64
target_triple: x86_64-unknown-linux-musl
package: x86_64-linux-musl-cross
custom_env:
CC: x86_64-linux-musl-gcc
CXX: x86_64-linux-musl-g++
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: x86_64-linux-musl-g++
RUSTC_LINKER: x86_64-linux-musl-g++
RUSTFLAGS: -C target-cpu=x86-64-v3
- target: arm64
target_triple: aarch64-unknown-linux-musl
package: aarch64-linux-musl-cross
custom_env:
CC: aarch64-linux-musl-gcc
CXX: aarch64-linux-musl-g++
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-g++
RUSTC_LINKER: aarch64-linux-musl-g++
BINDGEN_EXTRA_CLANG_ARGS: "--sysroot=/opt/aarch64-linux-musl-cross/aarch64-linux-musl"
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target_triple }}
- name: Install base dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake perl pkg-config libclang-dev musl-tools
- name: Prepare musl cross-compiler
run: |
wget https://github.com/musl-cc/musl.cc/releases/latest/download/${{ matrix.package }}.tgz
tar xzf ${{ matrix.package }}.tgz -C /opt
echo "/opt/${{ matrix.package }}/bin/" >> $GITHUB_PATH
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Build
env: ${{ matrix.custom_env }}
run: cargo build --release --target ${{ matrix.target_triple }}
- name: Archive
run: |
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-linux-${{ matrix.target }}-musl
path: dist/
windows:
needs: [lint-audit, test]
name: Build Windows
runs-on: windows-latest
strategy:
matrix:
include:
- target: x86_64
target_triple: x86_64-pc-windows-msvc
custom_env:
RUSTFLAGS: -C target-cpu=x86-64-v3
- target: arm64
target_triple: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target_triple }}
- name: Install dependencies
run: choco install cmake strawberryperl pkgconfiglite llvm nasm -y
shell: cmd
- name: Build
env:
RUSTFLAGS: "-C target-feature=+crt-static"
run: |
rustup target add ${{ matrix.target_triple }}
cargo build --release --target ${{ matrix.target_triple }}
- name: Archive
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target\${{ matrix.target_triple }}\release\client.exe" -Destination dist\
Copy-Item "target\${{ matrix.target_triple }}\release\server.exe" -Destination dist\
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-windows-${{ matrix.target }}
path: dist/
darwin:
needs: [lint-audit, test]
name: Build Darwin
runs-on: macos-latest
strategy:
matrix:
include:
- target: x86_64
target_triple: x86_64-apple-darwin
- target: arm64
target_triple: aarch64-apple-darwin
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target_triple }}
- name: Install dependencies
run: brew install llvm
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Build
run: cargo build --release --target ${{ matrix.target_triple }}
- name: Archive
run: |
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-darwin-${{ matrix.target }}
path: dist/
android:
needs: [lint-audit, test]
name: Build Android
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64
target_triple: x86_64-linux-android
- target: arm64
target_triple: aarch64-linux-android
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target_triple }}
- name: Install Android Tools
run: cargo install cargo-ndk
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Build
run: cargo ndk --target ${{ matrix.target_triple }} --platform 28 build --release
- name: Archive
run: |
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-android-${{ matrix.target }}
path: dist/
create-release:
needs: [linux-gnu, linux-musl, windows, darwin, android]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Generate Third-Party Licenses
run: |
cargo install cargo-bundle-licenses
cargo bundle-licenses --format yaml --output THIRD-PARTY-LICENSES.txt
- name: Download All Artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: Final Packaging
run: |
mkdir final_dist
for dir in artifacts/*/; do
name=$(basename "$dir")
zip -j "final_dist/${name}.zip" "$dir"/* CONFIGURATION.md README.md LICENSE THIRD-PARTY-LICENSES.txt
done
cd final_dist
sha256sum *.zip > sha256sums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
final_dist/*.zip
final_dist/sha256sums.txt
generate_release_notes: true