forked from lwthiker/curl-impersonate
-
-
Notifications
You must be signed in to change notification settings - Fork 129
339 lines (315 loc) · 13.1 KB
/
build.yml
File metadata and controls
339 lines (315 loc) · 13.1 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: "Build on Linux/Darwin"
on:
workflow_call:
push:
branches:
- main
- feature/*
- bugfix/*
- chore/*
- security/*
pull_request:
branches:
- main
permissions:
contents: read
env:
BORING_SSL_COMMIT: 673e61fc215b178a90c0e67858bbf162c8158993
MACOSX_DEPLOYMENT_TARGET: 11.0
API: "21" # Targeting an very old android API version
jobs:
build:
name: (${{ matrix.host_label }}) Build curl-impersonate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x86_64
host: x86_64-linux-gnu
host_label: x86_64-linux-gnu
zigflags: -target x86_64-linux-gnu.2.17
make: make
- os: ubuntu-latest
platform: linux
arch: x86_64
host: x86_64-linux-musl
host_label: x86_64-linux-musl
zigflags: -target x86_64-linux-musl -fPIC
make: make
- os: ubuntu-latest
platform: linux
arch: i386
host: i386-linux-gnu
host_label: i386-linux-gnu
zigflags: -target x86-linux-gnu.2.17
make: make
- os: ubuntu-latest
platform: linux
arch: aarch64
host: aarch64-linux-gnu
host_label: aarch64-linux-gnu
zigflags: -target aarch64-linux-gnu.2.17
make: make
- os: ubuntu-latest
platform: linux
arch: aarch64
host: aarch64-linux-musl
host_label: aarch64-linux-musl
zigflags: -target aarch64-linux-musl -fPIC -mno-outline-atomics
make: make
- os: ubuntu-latest
platform: linux
arch: arm
host: arm-linux-gnueabihf
host_label: arm-linux-gnueabihf
zigflags: -target arm-linux-gnueabihf.2.17 -mcpu=arm1176jzf_s
make: make
- os: ubuntu-latest
platform: linux
arch: riscv64
host: riscv64-linux-gnu
host_label: riscv64-linux-gnu
zigflags: -target riscv64-linux-gnu.2.27
make: make
- os: ubuntu-latest
platform: linux
arch: loongarch64
host: loongarch64-linux-gnu
host_label: loongarch64-linux-gnu
zigflags: -target loongarch64-linux-gnu.2.36 -fPIC
make: make
- os: ubuntu-latest
platform: android
arch: aarch64
host: aarch64-linux-android
host_label: aarch64-linux-android
make: make
- os: macos-14
platform: ios
arch: arm64
host: arm64-apple-ios
host_label: arm64-apple-ios
ios_sdk: iphoneos
ios_min_version: "13.0"
make: gmake
- os: macos-14
platform: ios
arch: arm64-simulator
host: arm64-apple-ios
host_label: arm64-apple-ios-simulator
ios_sdk: iphonesimulator
ios_min_version: "13.0"
make: gmake
- os: macos-15-intel
platform: macos
arch: x86_64
host: x86_64-macos
host_label: x86_64-macos
make: gmake
- os: macos-14
platform: macos
arch: arm64
host: arm64-macos
host_label: arm64-macos
make: gmake
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up zig
if: matrix.platform == 'linux'
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.14.0
- name: Set zig env
if: matrix.platform == 'linux'
run: |
echo "CC=${{ github.workspace }}/zigshim/cc" >> $GITHUB_ENV
echo "CXX=${{ github.workspace }}/zigshim/cxx" >> $GITHUB_ENV
echo "AR=${{ github.workspace }}/zigshim/ar" >> $GITHUB_ENV
echo "ZIG_FLAGS=${{ matrix.zigflags }}" >> $GITHUB_ENV
- name: Set up Android NDK
if: matrix.platform == 'android'
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26d
- name: Set Android toolchain env
if: matrix.platform == 'android'
env:
NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
TARGET="${{ matrix.host }}"
echo "AR=$TOOLCHAIN/bin/llvm-ar" >> $GITHUB_ENV
echo "CC=$TOOLCHAIN/bin/${TARGET}${API}-clang" >> $GITHUB_ENV
echo "AS=$TOOLCHAIN/bin/${TARGET}${API}-clang" >> $GITHUB_ENV
echo "CXX=$TOOLCHAIN/bin/${TARGET}${API}-clang++" >> $GITHUB_ENV
echo "LD=$TOOLCHAIN/bin/ld" >> $GITHUB_ENV
echo "RANLIB=$TOOLCHAIN/bin/llvm-ranlib" >> $GITHUB_ENV
echo "STRIP=$TOOLCHAIN/bin/llvm-strip" >> $GITHUB_ENV
echo "CFLAGS=-fPIC" >> $GITHUB_ENV
echo "CXXFLAGS=-fPIC" >> $GITHUB_ENV
- name: Set iOS toolchain env
if: matrix.platform == 'ios'
run: |
SDKROOT="$(xcrun --sdk ${{ matrix.ios_sdk }} --show-sdk-path)"
CC="$(xcrun --sdk ${{ matrix.ios_sdk }} --find clang)"
CXX="$(xcrun --sdk ${{ matrix.ios_sdk }} --find clang++)"
AR="$(xcrun --sdk ${{ matrix.ios_sdk }} --find ar)"
RANLIB="$(xcrun --sdk ${{ matrix.ios_sdk }} --find ranlib)"
STRIP="$(xcrun --sdk ${{ matrix.ios_sdk }} --find strip)"
if [[ "${{ matrix.ios_sdk }}" == "iphoneos" ]]; then
min_flag="-miphoneos-version-min=${{ matrix.ios_min_version }}"
else
min_flag="-mios-simulator-version-min=${{ matrix.ios_min_version }}"
fi
echo "SDKROOT=$SDKROOT" >> $GITHUB_ENV
echo "IOS_MIN_VERSION=${{ matrix.ios_min_version }}" >> $GITHUB_ENV
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CXX" >> $GITHUB_ENV
echo "AR=$AR" >> $GITHUB_ENV
echo "RANLIB=$RANLIB" >> $GITHUB_ENV
echo "STRIP=$STRIP" >> $GITHUB_ENV
echo "CFLAGS=-isysroot $SDKROOT -arch arm64 $min_flag -fPIC" >> $GITHUB_ENV
echo "CXXFLAGS=-isysroot $SDKROOT -arch arm64 $min_flag -fPIC" >> $GITHUB_ENV
echo "LDFLAGS=-isysroot $SDKROOT -arch arm64 $min_flag" >> $GITHUB_ENV
- name: Install Ubuntu dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install build-essential pkg-config cmake ninja-build curl autoconf automake libtool
sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-riscv64-linux-gnu gcc-14-loongarch64-linux-gnu
sudo apt-get install golang-go
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install pkg-config make cmake ninja autoconf automake libtool gpatch
# Chrome version dependencies, install only not installed.
which go || brew install go
# Dependencies for the tests
brew install tcpdump curl nghttp2
- name: Run configure script
run: |
set -e
mkdir ${{ runner.temp }}/install
if [[ "${{ matrix.platform }}" == "ios" ]]; then
./configure --prefix=${{ runner.temp }}/install --enable-static --disable-shared \
--host=${{ matrix.host }}
elif [[ "${{ runner.os }}" == "Linux" ]]; then
./configure --prefix=${{ runner.temp }}/install --enable-static --disable-shared \
--host=${{ matrix.host }} \
--with-ca-path=/etc/ssl/certs \
--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt
else
./configure --prefix=${{ runner.temp }}/install --enable-static --disable-shared
fi
- name: Build statically
run: |
set -e
${{ matrix.make }} build
${{ matrix.make }} checkbuild
if [[ "${{ runner.os }}" == "Linux" && "${{ endsWith(matrix.host, 'musl') }}" == "true" ]]; then
${{ matrix.make }} install
else
${{ matrix.make }} install-strip
fi
- name: Create tar release files
run: |
cp zlib-*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp zstd-*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp nghttp2*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp nghttp3*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp ngtcp2*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp brotli*/out/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp boringssl*/lib/lib*.a ${{ runner.temp }}/install/lib
if [[ "${{ matrix.platform }}" == "linux" ]]; then
cp libidn2*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
cp libunistring*/installed/lib/lib*.a ${{ runner.temp }}/install/lib
fi
cd ${{ runner.temp }}/install/lib
mv libcurl-impersonate.a libcurl-impersonate.orig.a
lib_list="libcurl-impersonate.orig.a libz.a libzstd.a libbrotlidec.a libbrotlicommon.a libbrotlienc.a libnghttp2.a libnghttp3.a libngtcp2.a libngtcp2_crypto_boringssl.a libssl.a libcrypto.a"
if [[ "${{ matrix.platform }}" == "linux" ]]; then
lib_list="$lib_list libidn2.a"
fi
if [[ "${{ runner.os }}" == "macOS" || "${{ matrix.platform }}" == "ios" ]]; then
libtool -static -o libcurl-impersonate.a $lib_list
else
$CC -r -o libcurl-impersonate.full.o -Wl,--whole-archive $lib_list -Wl,--no-whole-archive
ar rcs libcurl-impersonate.a libcurl-impersonate.full.o
rm -f libcurl-impersonate.full.o
fi
rm -f libz.a libzstd.a libbrotlidec.a libbrotlicommon.a libbrotlienc.a libnghttp2.a libnghttp3.a libngtcp2.a libngtcp2_crypto_boringssl.a libssl.a libcrypto.a
if [[ "${{ matrix.platform }}" == "linux" ]]; then
rm -f libidn2.a libunistring.a
fi
rm -f libcurl-impersonate.orig.a
ls -lah .
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
tar -c -z -f ${{ runner.temp }}/libcurl-impersonate-${{ github.ref_name }}.${{ matrix.host_label }}.tar.gz lib*
else
tar -c -z -f ${{ runner.temp }}/libcurl-impersonate.${{ matrix.host_label }}.tar.gz lib*
fi
cd ${{ runner.temp }}/install/bin
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
tar -c -z -f ${{ runner.temp }}/curl-impersonate-${{ github.ref_name }}.${{ matrix.host_label }}.tar.gz curl-impersonate curl_*
else
tar -c -z -f ${{ runner.temp }}/curl-impersonate.${{ matrix.host_label }}.tar.gz curl-impersonate curl_*
fi
- name: Create iOS XCFramework slice
if: matrix.platform == 'ios'
run: |
slice_dir="${{ runner.temp }}/ios-slice"
mkdir -p "$slice_dir/lib"
cp -R ${{ runner.temp }}/install/include "$slice_dir/"
cp ${{ runner.temp }}/install/lib/libcurl-impersonate.a "$slice_dir/lib/"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts.${{ matrix.host_label }}
path: |
${{ runner.temp }}/libcurl-impersonate*.tar.gz
${{ runner.temp }}/curl-impersonate*.tar.gz
- name: Upload iOS slice artifact
if: matrix.platform == 'ios'
uses: actions/upload-artifact@v4
with:
name: ios-slice.${{ matrix.host_label }}
path: ${{ runner.temp }}/ios-slice
ios-xcframework:
name: (iOS) Create XCFramework
runs-on: macos-14
needs: build
steps:
- name: Download device slice
uses: actions/download-artifact@v4
with:
name: ios-slice.arm64-apple-ios
path: ${{ runner.temp }}/ios/device
- name: Download simulator slice
uses: actions/download-artifact@v4
with:
name: ios-slice.arm64-apple-ios-simulator
path: ${{ runner.temp }}/ios/simulator
- name: Create XCFramework
run: |
xcodebuild -create-xcframework \
-library ${{ runner.temp }}/ios/device/lib/libcurl-impersonate.a \
-headers ${{ runner.temp }}/ios/device/include \
-library ${{ runner.temp }}/ios/simulator/lib/libcurl-impersonate.a \
-headers ${{ runner.temp }}/ios/simulator/include \
-output ${{ runner.temp }}/libcurl-impersonate.xcframework
cd ${{ runner.temp }}
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
tar -c -z -f ${{ runner.temp }}/libcurl-impersonate-${{ github.ref_name }}.ios-xcframework.tar.gz libcurl-impersonate.xcframework
else
tar -c -z -f ${{ runner.temp }}/libcurl-impersonate.ios-xcframework.tar.gz libcurl-impersonate.xcframework
fi
- name: Upload XCFramework artifact
uses: actions/upload-artifact@v4
with:
name: artifacts.ios-xcframework
path: ${{ runner.temp }}/libcurl-impersonate*.ios-xcframework.tar.gz