-
Notifications
You must be signed in to change notification settings - Fork 36
302 lines (288 loc) · 11.5 KB
/
build-natives.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
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
name: Build Native Libraries
on:
workflow_dispatch:
inputs:
build-config:
required: true
default: 'release'
type: choice
options:
- debug
- release
build-only-linux:
required: true
default: false
type: boolean
update-unity-native:
required: true
default: false
type: boolean
workflow_call:
inputs:
build-config:
required: true
type: string
build-only-linux:
required: true
type: boolean
update-unity-native:
required: true
type: boolean
env:
_RUST_BUILD_CONFIG: ${{ inputs.build-config == 'debug' && 'debug' || 'release' }}
_DOTNET_BUILD_CONFIG: ${{ inputs.build-config == 'debug' && 'Debug' || 'Release' }}
jobs:
build-win-x64:
name: Build Native library (win-x64)
if: ${{ !inputs.build-only-linux }}
runs-on: windows-2022
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: cargo build --target x86_64-pc-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: win-x64
path: native/target/x86_64-pc-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll
retention-days: 1
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-win-arm64:
name: Build Native library (win-arm64)
if: ${{ !inputs.build-only-linux }}
runs-on: windows-2022
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: rustup target add aarch64-pc-windows-msvc
- run: |
$env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin"
cargo build --target aarch64-pc-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: win-arm64
path: native/target/aarch64-pc-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll
retention-days: 1
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-win-arm64-uwp:
name: Build Native library (win-arm64-uwp)
if: ${{ !inputs.build-only-linux }}
runs-on: windows-2022
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: rustup toolchain install nightly-x86_64-pc-windows-msvc
- run: rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
- run: rustup default nightly
- run: |
$env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin"
cargo -Z build-std build --target aarch64-uwp-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: win-arm64-uwp
path: native/target/aarch64-uwp-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll
retention-days: 1
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-linux-x64:
name: Build Native library (linux-x64)
runs-on: ubuntu-20.04
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: cargo build --target x86_64-unknown-linux-gnu --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: linux-x64
path: native/target/x86_64-unknown-linux-gnu/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so
retention-days: 1
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-osx-x64:
name: Build Native library (osx-x64)
if: ${{ !inputs.build-only-linux }}
runs-on: macos-13 # Intel
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
- run: rustup target add x86_64-apple-darwin
- run: cargo build --target x86_64-apple-darwin --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: osx-x64
path: native/target/x86_64-apple-darwin/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.dylib
retention-days: 1
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-osx-arm64:
name: Build Native library (osx-arm64)
if: ${{ !inputs.build-only-linux }}
runs-on: macos-latest # Apple Silicon
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: rustup target add aarch64-apple-darwin
- run: cargo build --target aarch64-apple-darwin --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: osx-arm64
path: native/target/aarch64-apple-darwin/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.dylib
retention-days: 1
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test
build-ios-x64:
name: Build Native library (ios-x64)
if: ${{ !inputs.build-only-linux }}
runs-on: macos-latest
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: rustup target add x86_64-apple-ios
- run: cargo build --target x86_64-apple-ios --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: ios-x64
path: native/target/x86_64-apple-ios/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.a
retention-days: 1
build-ios-arm64:
name: Build Native library (ios-arm64)
if: ${{ !inputs.build-only-linux }}
runs-on: macos-latest
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: rustup target add aarch64-apple-ios
- run: cargo build --target aarch64-apple-ios --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: ios-arm64
path: native/target/aarch64-apple-ios/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.a
retention-days: 1
build-android-arm:
name: Build Native library (android-arm)
if: ${{ !inputs.build-only-linux }}
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt install gcc-multilib
- run: rustup target add armv7-linux-androideabi
- run: cargo install cargo-ndk
- run: cargo ndk -t armeabi-v7a build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: android-arm
path: native/target/armv7-linux-androideabi/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so
retention-days: 1
build-android-arm64:
name: Build Native library (android-arm64)
if: ${{ !inputs.build-only-linux }}
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt install gcc-multilib
- run: rustup target add aarch64-linux-android
- run: cargo install cargo-ndk
- run: cargo ndk -t arm64-v8a build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: android-arm64
path: native/target/aarch64-linux-android/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so
retention-days: 1
build-android-x64:
name: Build Native library (android-x64)
if: ${{ !inputs.build-only-linux }}
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt install gcc-multilib
- run: rustup target add x86_64-linux-android
- run: cargo install cargo-ndk
- run: cargo ndk -t x86_64 build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: android-x64
path: native/target/x86_64-linux-android/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so
retention-days: 1
build-dotnet:
name: Build and pack .NET library
if: ${{ inputs.build-only-linux && needs.build-linux-x64.result == 'success' || success() }}
needs:
- build-win-x64
- build-win-arm64
- build-win-arm64-uwp
- build-linux-x64
- build-osx-x64
- build-osx-arm64
- build-ios-x64
- build-ios-arm64
- build-android-arm
- build-android-arm64
- build-android-x64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/download-artifact@main
with:
path: native/artifacts
- run: ls -lFaR native/artifacts
- run: dotnet pack -c ${{ env._DOTNET_BUILD_CONFIG }} ./YetAnotherHttpHandler.sln --include-symbols --include-source -o ./publish
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ./test/YetAnotherHttpHandler.Packaging.Test
- uses: Cysharp/Actions/.github/actions/upload-artifact@main
with:
name: nuget-packages
path: ./publish/
retention-days: 7
update-unity-native:
name: Update pre-built libraries for Unity
if: ${{ inputs.update-unity-native && (inputs.build-only-linux && needs.build-dotnet.result == 'success' || success()) }}
needs: [ build-dotnet ]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: Cysharp/Actions/.github/actions/download-artifact@main
with:
name: nuget-packages
path: ./publish/
- run: unzip -o ./publish/YetAnotherHttpHandler.*[0-9].nupkg 'runtimes/*' -d src/YetAnotherHttpHandler/Plugins/Cysharp.Net.Http.YetAnotherHttpHandler.Native/ || true
- run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update pre-built native libraries" src/YetAnotherHttpHandler/Plugins/**/*
git push origin ${{ github.ref_name }}