-
-
Notifications
You must be signed in to change notification settings - Fork 116
373 lines (368 loc) · 14.7 KB
/
compilation.yml
File metadata and controls
373 lines (368 loc) · 14.7 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
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
name: Automatic build
on: [push, pull_request]
jobs:
# To setup secrets for client build, see https://game.ci/docs/github/activation
# NOTE: For personal license, a dedicated account is recommended
# NOTE: To generate the license file, open Unity 2018 on a project at least once
check-secret:
name: Check if secrets available
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
secret-is-set: ${{ steps.secret-is-set.outputs.defined }}
android-secret-is-set: ${{ steps.android-secret-is-set.outputs.defined }}
steps:
- name: Check if secret is set, then set variable
id: secret-is-set
env:
TMP_SECRET1: ${{ secrets.UNITY_LICENSE }}
TMP_SECRET2: ${{ secrets.UNITY_EMAIL }}
TMP_SECRET3: ${{ secrets.UNITY_PASSWORD }}
if: "${{ env.TMP_SECRET1 != '' && env.TMP_SECRET2 != '' && env.TMP_SECRET3 != '' }}"
run: echo "defined=true" >> $GITHUB_OUTPUT
- name: Check if Android secrets are set, then set variable
id: android-secret-is-set
env:
TMP_SECRET1: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
TMP_SECRET2: ${{ secrets.ANDROID_KEYSTORE_PASS }}
TMP_SECRET3: ${{ secrets.ANDROID_KEYALIAS_NAME }}
TMP_SECRET4: ${{ secrets.ANDROID_KEYALIAS_PASS }}
if: "${{ env.TMP_SECRET1 != '' && env.TMP_SECRET2 != '' && env.TMP_SECRET3 != '' && env.TMP_SECRET4 != '' }}"
run: echo "defined=true" >> $GITHUB_OUTPUT
build-client:
name: Build client for ${{ matrix.targetPlatform }}
timeout-minutes: 100
runs-on: ${{ matrix.buildPlatform }}
permissions:
actions: write # to allow us to manage cache
env:
projectPath: Basis
buildName: Basis Unity
strategy:
fail-fast: false
matrix:
targetPlatform:
- StandaloneLinux64
buildPlatform:
- ubuntu-latest
include:
- buildPlatform: windows-2022
targetPlatform: StandaloneWindows64
needs: [check-secret]
if: needs.check-secret.outputs.secret-is-set == 'true'
steps:
# We're running out of disk space in some cases. However, the actual build is happening in a docker container.
# Therefore, we don't actually need most of the tools that github provides. This can save quite a bit of space.
# Also consider https://github.com/easimon/maximize-build-space/, which pulls some other tricks.
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
if: matrix.buildPlatform == 'ubuntu-latest'
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: false
- name: "Checkout repository"
timeout-minutes: 10
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Restore Library cache"
id: restore-cache
timeout-minutes: 10
uses: actions/cache/restore@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-${{ matrix.targetPlatform }}-client-${{ hashFiles(env.projectPath) }}
restore-keys: Library-${{ env.projectPath }}-${{ matrix.targetPlatform }}-client-
- name: "Create version string"
id: version
run: echo "gitversion=$(git describe --tags --always)" >> "$GITHUB_OUTPUT"
- name: "Remove OpenXR when building for Linux"
if: matrix.targetPlatform == 'StandaloneLinux64'
run: rm -rf ${projectPath}/Packages/com.basis.openxr
# run: jq 'del(.dependencies ["com.unity.xr.openxr"])' < ${projectPath}/Packages/manifest.json > manifest.json.tmp && mv manifest.json.tmp ${projectPath}/Packages/manifest.json
- name: "Remove Meta XR Core when building for Linux"
if: matrix.targetPlatform == 'StandaloneLinux64'
run: rm -rf ${projectPath}/Packages/com.meta.xr.sdk.core
# Fix docker not ready on windows
- name: Ensure Docker service is running
if: matrix.buildPlatform == 'windows-2022'
shell: powershell
run: |
Start-Service docker
- name: Wait for Docker to be ready
if: matrix.buildPlatform == 'windows-2022'
shell: powershell
run: |
$maxAttempts = 40
for ($i=0; $i -lt $maxAttempts; $i++) {
docker info > $null 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "Docker is ready"
exit 0
}
Write-Host "Waiting for Docker..."
Start-Sleep -Seconds 3
}
throw "Docker did not become ready in time"
- name: "Build Unity project"
timeout-minutes: 100
uses: BasisVR/unity-builder@main
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
buildName: ${{ env.buildName }}
projectPath: ${{ env.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}
customParameters: ${{ startsWith(matrix.targetPlatform, 'Standalone') && '-standaloneBuildSubtarget Player' || '' }}
versioning: Custom
version: ${{ steps.version.outputs.gitversion }}
linux64RemoveExecutableExtension: false
- name: "Save Library Cache"
uses: actions/cache/save@v3
if: always() && github.ref_name == 'developer'
with:
path: ${{ env.projectPath }}/Library
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: "Only retain latest cache"
if: always() && github.ref_name == 'developer'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
OLD_CACHE_IDS=$(gh cache list --sort created_at --key Library-${{ env.projectPath }}-${{ matrix.targetPlatform }}-client- --json id --jq '.[1:] | map(.id) | @sh')
for cache_id in $OLD_CACHE_IDS; do
echo "Deleting cache id: $cache_id"
gh cache delete $cache_id
done
- name: "Upload client artifact"
timeout-minutes: 2
uses: actions/upload-artifact@v4
with:
name: Basis-Client-${{ matrix.targetPlatform }}
path: |
build/${{ matrix.targetPlatform }}
!build/${{ matrix.targetPlatform }}/${{ env.buildName }}_BackUpThisFolder_ButDontShipItWithYourGame
- name: "Upload client symbols artifact"
timeout-minutes: 4
uses: actions/upload-artifact@v4
with:
name: Basis-Symbols-Client-${{ matrix.targetPlatform }}
path: |
build/${{ matrix.targetPlatform }}/${{ env.buildName }}_BackUpThisFolder_ButDontShipItWithYourGame
- name: Archive symbols
uses: thedoctor0/zip-release@0.7.6
if: github.ref_type == 'tag' && matrix.targetPlatform != 'Android'
with:
type: "zip"
directory: build/${{ matrix.targetPlatform }}
filename: "${{ github.workspace }}/Basis Unity ${{ matrix.targetPlatform }} Symbols.zip"
# This uses a wildcard because this action doesn't work correctly with spaces in path.
path: "*_BackUpThisFolder_ButDontShipItWithYourGame"
# workaround for exclusions not working with spaces *or* wildcards.
- name: Delete symbols
if: github.ref_type == 'tag' && matrix.targetPlatform != 'Android'
shell: bash
run: >
${{ matrix.buildPlatform == 'ubuntu-latest' && 'sudo' || '' }}
rm -rvf "build/${{ matrix.targetPlatform }}/${{ env.buildName }}_BackUpThisFolder_ButDontShipItWithYourGame"
- name: Archive client
uses: thedoctor0/zip-release@0.7.6
if: github.ref_type == 'tag' && matrix.targetPlatform != 'Android'
with:
type: "zip"
directory: build/${{ matrix.targetPlatform }}
filename: "${{ github.workspace }}/Basis Unity ${{ matrix.targetPlatform }}.zip"
- name: "Release client zip"
if: github.ref_type == 'tag' && matrix.targetPlatform != 'Android'
timeout-minutes: 5
uses: "softprops/action-gh-release@v2"
with:
files: |
${{ github.workspace }}/Basis Unity ${{ matrix.targetPlatform }}.zip
${{ github.workspace }}/Basis Unity ${{ matrix.targetPlatform }} Symbols.zip
build-client-android:
name: Build client for Android
timeout-minutes: 100
runs-on: ubuntu-latest
permissions:
actions: write # to allow us to manage cache
env:
projectPath: Basis
buildName: Basis Unity
needs: [check-secret]
if: needs.check-secret.outputs.secret-is-set == 'true' && needs.check-secret.outputs.android-secret-is-set == 'true'
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: false
- name: "Checkout repository"
timeout-minutes: 10
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Restore Library cache"
id: restore-cache
timeout-minutes: 10
uses: actions/cache/restore@v3
with:
path: ${{ env.projectPath }}/Library
key: Library-${{ env.projectPath }}-Android-client-${{ hashFiles(env.projectPath) }}
restore-keys: Library-${{ env.projectPath }}-Android-client-
- name: "Create version string"
id: version
run: echo "gitversion=$(git describe --tags --always)" >> "$GITHUB_OUTPUT"
- name: "Build Unity project"
timeout-minutes: 100
uses: BasisVR/unity-builder@main
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
buildName: ${{ env.buildName }}
projectPath: ${{ env.projectPath }}
targetPlatform: Android
customParameters: ""
versioning: Custom
version: ${{ steps.version.outputs.gitversion }}
# TODO: make a decision on how we want to increment this.
# This number was chosen to be slightly larger than the version code used for 0.056B.
androidVersionCode: 55
androidExportType: androidPackage
androidKeystoreName: BasisQuest # This file won't exist, but this property needs to exist.
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
linux64RemoveExecutableExtension: false
- name: "Save Library Cache"
uses: actions/cache/save@v3
if: always() && github.ref_name == 'developer'
with:
path: ${{ env.projectPath }}/Library
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: "Only retain latest cache"
if: always() && github.ref_name == 'developer'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
OLD_CACHE_IDS=$(gh cache list --sort created_at --key Library-${{ env.projectPath }}-Android-client- --json id --jq '.[1:] | map(.id) | @sh')
for cache_id in $OLD_CACHE_IDS; do
echo "Deleting cache id: $cache_id"
gh cache delete $cache_id
done
- name: "Upload client artifact"
timeout-minutes: 2
uses: actions/upload-artifact@v4
with:
name: Basis-Client-Android
path: |
build/Android
!build/Android/${{ env.buildName }}_BackUpThisFolder_ButDontShipItWithYourGame
- name: "Upload client symbols artifact"
timeout-minutes: 4
uses: actions/upload-artifact@v4
with:
name: Basis-Symbols-Client-Android
path: |
build/Android/${{ env.buildName }}_BackUpThisFolder_ButDontShipItWithYourGame
- name: "Release client apk"
if: github.ref_type == 'tag'
timeout-minutes: 5
uses: "softprops/action-gh-release@v2"
with:
files: build/Android/${{ env.buildName }}.apk
build-server:
name: Build server on Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
projectPath:
- Basis Server
runtimes:
- linux-x64
- linux-musl-x64
- linux-musl-arm64
- linux-arm64
- win-x64
steps:
- name: "Checkout repository"
timeout-minutes: 10
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setup dotnet"
timeout-minutes: 2
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: "Build server"
timeout-minutes: 10
run: "dotnet publish '${{ matrix.projectPath }}' -f net10.0 --self-contained --runtime '${{ matrix.runtimes }}' -o build -c Release"
- name: "Upload server artifact"
timeout-minutes: 2
uses: actions/upload-artifact@v4
with:
name: Basis-Server-${{ matrix.runtimes }}
path: "build"
- name: Archive Release
uses: thedoctor0/zip-release@0.7.6
if: github.ref_type == 'tag'
with:
type: "zip"
directory: build
filename: "Basis Server ${{ matrix.runtimes }}.zip"
- name: "Release server zip"
if: github.ref_type == 'tag'
timeout-minutes: 5
uses: "softprops/action-gh-release@v2"
with:
files: build/Basis Server ${{ matrix.runtimes }}.zip
compile-unitypackages:
name: Build .unitypackage files
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: "Checkout repository"
timeout-minutes: 5
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Produce SDK unitypackage."
timeout-minutes: 5
run: .github/scripts/unitypackagegen.sh sdk
- name: "Produce full unitypackage."
timeout-minutes: 5
run: .github/scripts/unitypackagegen.sh full
- uses: actions/upload-artifact@v4
timeout-minutes: 5
with:
name: unitypackage_upload
path: |
Basis/Basis.sdk.unitypackage
Basis/Basis.full.unitypackage
- name: "Release unitypackage"
if: github.ref_type == 'tag'
timeout-minutes: 5
uses: "softprops/action-gh-release@v2"
with:
files: |
Basis/Basis.sdk.unitypackage
Basis/Basis.full.unitypackage