-
-
Notifications
You must be signed in to change notification settings - Fork 3
413 lines (369 loc) · 20.1 KB
/
Mochi.PhysX.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
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: Mochi.PhysX
on:
push:
# This prevents tag pushes from triggering this workflow
branches: ['*']
pull_request:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version"
default: ""
will_publish_packages:
description: "Publish packages?"
default: "false"
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
ContinuousIntegrationBuild: true
# This URL will be added to the restore sources if it isn't the official NuGet.org
# (This is mainly intended to allow using the NuGet.org test servers to test CI in forks.)
CiNuGetApiUrl: ${{secrets.NUGET_API_URL}}
jobs:
# =====================================================================================================================================================================
# Build PhysX
# =====================================================================================================================================================================
build-physx:
strategy:
fail-fast: false
matrix:
rid: [win-x64]
configuration:
- name: Debug
id: debug
- name: Checked
id: checked
- name: Profile
id: profile
- name: Release
id: release
include:
- rid: win-x64
name: Windows x64
os: windows-2019
build-command: ./build.cmd
physx-install-path: external/PhysX/physx/install/Mochi.PhysX.Windows.x64
physx-compiler-path: external/PhysX/physx/compiler/mochi-physx-win-x64
name: PhysX ${{matrix.name}} ${{matrix.configuration.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
# ----------------------------------------------------------------------- Setup Python
- name: Setup Python 3.8
if: matrix.platform.skip-tool-install != true
uses: actions/setup-python@v2
with:
python-version: '3.8'
# ----------------------------------------------------------------------- Get PhysX revision
- name: Get PhysX revision
id: physx
run: python .github/workflows/get-physx-revision.py
# ----------------------------------------------------------------------- Build PhysX
- name: Load cached PhysX build outputs
id: cached-physx
uses: actions/cache@v2
with:
key: physx-${{matrix.rid}}-${{matrix.configuration.id}}-${{steps.physx.outputs.revision}}-${{hashFiles('build.*', 'tooling/*.cmd', 'tooling/*.sh', 'Mochi.PhysX.Modifications/**')}}
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
- name: Build PhysX
if: steps.cached-physx.outputs.cache-hit != 'true'
run: ${{matrix.build-command}} ${{matrix.configuration.id}}
# ----------------------------------------------------------------------- Upload artifacts
- name: Collect PhysX binaries
if: steps.cached-physx.outputs.cache-hit != 'true'
run: tar -cvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/bin
# Due to the way PhysX builds and links its internal dependencies, the PDBs it emits don't include some internal object files
# However, the linker will be able to automagically find the debug info for these objects from these PDBs so we include them in our archive
# (Not including these causes LNK4099 to be spammed for all of these objects when Mochi.PhysX.Native is built and presumably causes these objects to be missing debug info.)
- name: Collect extra PhysX PDBs
if: steps.cached-physx.outputs.cache-hit != 'true' && runner.os == 'Windows'
run: tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-compiler-path}}/sdk_source_bin/${{matrix.configuration.id}}/*.pdb
# We only use the headers from the release build (they should match between all of them)
# (These are the headers we actually use to generate the bindings.)
# This also includes the PhysX license file to let subsequent jobs avoid cloning PhysX for it
- name: Collect PhysX headers
if: steps.cached-physx.outputs.cache-hit != 'true' && matrix.configuration.id == 'release'
run: |
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/include
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar ${{matrix.physx-install-path}}/source
tar -rvf physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar external/PhysX/LICENSE.md
- name: Compress PhysX build artifacts
if: steps.cached-physx.outputs.cache-hit != 'true'
run: gzip physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar
- name: Upload PhysX build artifacts
uses: actions/upload-artifact@v2
with:
name: physx-${{matrix.rid}}
path: physx-${{matrix.rid}}-${{matrix.configuration.id}}.tar.gz
if-no-files-found: error
# =====================================================================================================================================================================
# Build Mochi.PhysX
# =====================================================================================================================================================================
build-mochi-physx:
needs: build-physx
strategy:
fail-fast: false
matrix:
include:
- name: Windows x64
os: windows-2019
rid: win-x64
build-command: ./build.cmd
name: Mochi.PhysX ${{matrix.name}}
runs-on: ${{matrix.os}}
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
# We intentionally don't checkout submodules here, Mochi.PhysX.Generator should only use outputs from building PhysX
uses: actions/checkout@v2
#TODO: Actually we need them for Biohazrd still. Remove this once we switch to NuGet packages for it.
with:
submodules: recursive
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
if: matrix.platform.skip-tool-install != true
uses: actions/setup-dotnet@v1
with:
# We need both the .NET 5 and .NET 6 SDKs because we currently use C# 10 while targeting .NET 5
dotnet-version: |
5.0.x
6.0.x
# ----------------------------------------------------------------------- Download PhysX builds
- name: Download PhysX ${{matrix.name}} builds
uses: actions/download-artifact@v2
with:
name: physx-${{matrix.rid}}
- name: Extract PhysX Builds
run: |
tar --keep-old-files -xvf physx-${{matrix.rid}}-debug.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-checked.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-profile.tar.gz
tar --keep-old-files -xvf physx-${{matrix.rid}}-release.tar.gz
# ----------------------------------------------------------------------- Configure build
- name: Configure build
run: python .github/workflows/configure-build.py
env:
github_event_name: ${{github.event_name}}
github_ref: ${{github.ref}}
github_run_number: ${{github.run_number}}
release_version: ${{github.event.release.tag_name}}
workflow_dispatch_version: ${{github.event.inputs.version}}
workflow_dispatch_will_publish_packages: ${{github.event.inputs.will_publish_packages}}
# ----------------------------------------------------------------------- Generate Mochi.PhysX
- name: Restore Mochi.PhysX.Generator
run: dotnet restore Mochi.PhysX.Generator
- name: Build Mochi.PhysX.Generator
run: dotnet build Mochi.PhysX.Generator --configuration Release
- name: Generate Mochi.PhysX
run: ${{matrix.build-command}} generate
# ----------------------------------------------------------------------- Build Mochi.PhysX
- name: Restore Mochi.PhysX.${{matrix.rid}}
# This is a workaround for the fact that the NuGet package name of Mochi.PhysX.Native changes depending on the configuration.
# Ideally we'd just manually specify the dependency but NuGet makes that really annoying to do. See https://github.com/NuGet/Home/issues/8133
env:
Configuration: Release
run: dotnet restore Mochi.PhysX --runtime ${{matrix.rid}}
- name: Build Mochi.PhysX.${{matrix.rid}}
run: dotnet build Mochi.PhysX --no-restore --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Pack Mochi.PhysX
- name: Pack Mochi.PhysX.${{matrix.rid}}
run: dotnet pack Mochi.PhysX --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Pack Mochi.PhysX.Native variants
- name: Restore Mochi.PhysX.Native
run: dotnet restore Mochi.PhysX.Native --runtime ${{matrix.rid}}
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-debug
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=debug
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-checked
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=checked
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}-profile
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=profile
- name: Pack Mochi.PhysX.Native.${{matrix.rid}}
run: dotnet pack Mochi.PhysX.Native --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}} /p:MochiPhysXNativeBuildVariant=release
# ----------------------------------------------------------------------- Pack Mochi.PhysX.Ref
# (This package is currently just a dummy package which references Mochi.PhysX.win-x64. Eventually it will be a least common denominator reference-only package.)
- name: Restore Mochi.PhysX.Ref
if: matrix.rid == 'win-x64'
run: dotnet restore Mochi.PhysX.Ref --runtime ${{matrix.rid}}
- name: Pack Mochi.PhysX.Ref
if: matrix.rid == 'win-x64'
run: dotnet pack Mochi.PhysX.Ref --no-build --configuration Release /p:RuntimeIdentifier=${{matrix.rid}}
# ----------------------------------------------------------------------- Run the sample as a smoke test
# We do this last so it can't indirectly affect the build process of any packages
- name: Test Mochi.PhysX.Sample (Debug)
run: dotnet run --project Mochi.PhysX.Sample --configuration Debug
- name: Test Mochi.PhysX.Sample (Release)
run: dotnet run --project Mochi.PhysX.Sample --configuration Release
# ----------------------------------------------------------------------- Upload artifacts
# All of these steps ignore failure so that we get what artifacts are available when things are broken
- name: Collect native binaries
if: always()
run: tar -cvzf Mochi.PhysX.Native-${{matrix.rid}}.tar.gz bin/Mochi.PhysX.Native
- name: Upload native binaries
if: always()
uses: actions/upload-artifact@v2
with:
name: Mochi.PhysX.Native-${{matrix.rid}}
path: Mochi.PhysX.Native-${{matrix.rid}}.tar.gz
if-no-files-found: error
- name: Collect NuGet packages
if: always()
run: tar -cvzf Mochi.PhysX-packages-${{matrix.rid}}.tar.gz packages
- name: Upload NuGet packages
if: always()
uses: actions/upload-artifact@v2
with:
name: Packages
if-no-files-found: error
path: Mochi.PhysX-packages-${{matrix.rid}}.tar.gz
- name: Collect generated output
if: always()
#TODO: We should use the Biohazrd file writes log for this
run: tar -cvzf Mochi.PhysX-${{matrix.rid}}-generated.tar.gz Mochi.PhysX/#Generated Mochi.PhysX.Native/*.gen.*
- name: Upload generated output
if: always()
uses: actions/upload-artifact@v2
with:
name: Mochi.PhysX-${{matrix.rid}}-generated
path: Mochi.PhysX-${{matrix.rid}}-generated.tar.gz
if-no-files-found: error
# =====================================================================================================================================================================
# Publish NuGet Packages to GitHub
# =====================================================================================================================================================================
publish-packages-github:
name: Publish to GitHub
runs-on: ubuntu-latest
needs: build-mochi-physx
# Pushes always publish CI packages (configure-build.py will add the branch name to the version string for branches besides main)
# Published releases always publish packages
# A manual workflow only publishes packages if explicitly enabled
if: github.event_name == 'push' || github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true')
steps:
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v2
with:
name: Packages
- name: Extract built packages
run: for archive in Mochi.PhysX-packages-*.tar.gz; do tar --keep-old-files -xvf "$archive"; done
# ----------------------------------------------------------------------- Push to GitHub Packages
- name: Push to GitHub Packages
run: dotnet nuget push "packages/*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/${{github.repository_owner}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
# =====================================================================================================================================================================
# Publish NuGet Packages to NuGet.org
# =====================================================================================================================================================================
publish-packages-nuget-org:
name: Publish to NuGet.org
runs-on: ubuntu-latest
needs: build-mochi-physx
environment: NuGet.org
# Release builds always publish packages to NuGet.org
# Workflow dispatch builds will only publish packages if enabled and an explicit version number is given
# Make sure this logic matches configure-build.py to ensure we don't accidentally depend on sibling CI pre-release packages
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.will_publish_packages == 'true' && github.event.inputs.version != '')
steps:
# ----------------------------------------------------------------------- Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
# ----------------------------------------------------------------------- Download built packages
- name: Download built packages
uses: actions/download-artifact@v2
with:
name: Packages
- name: Extract built packages
run: for archive in Mochi.PhysX-packages-*.tar.gz; do tar --keep-old-files -xvf "$archive"; done
# ----------------------------------------------------------------------- Push to NuGet.org
- name: Push to NuGet.org
run: dotnet nuget push "packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{secrets.NUGET_API_URL}}
env:
# This is a workaround for https://github.com/NuGet/Home/issues/9775
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
# =====================================================================================================================================================================
# Publish Release Assets
# =====================================================================================================================================================================
publish-release-assets:
name: Publish Release Assets
runs-on: ubuntu-latest
needs: build-mochi-physx
if: github.event_name == 'release'
steps:
# ----------------------------------------------------------------------- Download all artifacts
- name: Download artifacts
uses: actions/download-artifact@v2
# ----------------------------------------------------------------------- Upload release assets
- name: Upload release assets
uses: actions/github-script@v4
with:
user-agent: actions/github-script for ${{github.repository}}
script: |
const fs = require('fs').promises;
const path = require('path');
const uploadUrl = context.payload.release.upload_url;
if (!uploadUrl) {
throw "Missing release asset upload URL!";
}
async function uploadAssets(directoryPath) {
for (let filePath of await fs.readdir(directoryPath)) {
filePath = path.join(directoryPath, filePath);
const stats = await fs.stat(filePath);
if (stats.isDirectory()) {
console.log(`Entering '${filePath}'`);
await uploadAssets(filePath);
continue;
}
console.log(`Uploading '${filePath}'`);
await github.repos.uploadReleaseAsset({
url: uploadUrl,
headers: {
'content-type': 'application/octet-stream',
'content-length': stats.size
},
name: path.basename(filePath),
data: await fs.readFile(filePath)
});
}
}
await uploadAssets('.');
# =====================================================================================================================================================================
# Send CI Failure Notification
# =====================================================================================================================================================================
send-ci-failure-notification:
name: Send CI Failure Notification
needs: [build-physx, build-mochi-physx, publish-packages-github, publish-packages-nuget-org, publish-release-assets]
if: failure() && github.event_name != 'pull_request'
continue-on-error: true
runs-on: ubuntu-latest
steps:
# ----------------------------------------------------------------------- Checkout
- name: Checkout
uses: actions/checkout@v2
# ----------------------------------------------------------------------- Setup Python
- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
# ----------------------------------------------------------------------- Send CI Failure Notification
- name: Send Notification
run: python .github/workflows/send-ci-failure-notification.py
env:
webhook_url: ${{secrets.TEAMS_WEBHOOK_URL}}
github_organization: ${{github.repository_owner}}
github_repo: ${{github.repository}}
github_workflow_name: ${{github.workflow}}
github_run_number: ${{github.run_id}}