-
Notifications
You must be signed in to change notification settings - Fork 14
703 lines (631 loc) · 27.2 KB
/
build-unitycloud.yml
File metadata and controls
703 lines (631 loc) · 27.2 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
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
name: Unity Cloud Build
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
- labeled
merge_group: {}
push:
branches:
- dev
workflow_dispatch:
inputs:
profile:
description: 'Select level of profiling'
required: true
default: 'none'
type: choice
options:
- none
- profile
- deep
compression:
description: 'Level of compression'
required: true
default: 'LZ4HC'
type: choice
options:
- None
- LZ4
- LZ4HC
clean_build:
description: 'Clean Build'
required: false
default: false
type: boolean
cache_strategy:
description: 'Select cache strategy'
required: true
default: 'library'
type: choice
options:
- none
- library
- workspace
- inherit
sentry_enabled:
description: 'Enable Sentry'
required: false
type: boolean
default: false
delta_threshold_macos_mb:
description: 'Warn if macOS growth > this MB (0 = off)'
required: false
default: '0'
type: string
delta_threshold_windows_mb:
description: 'Warn if Windows growth > this MB (0 = off)'
required: false
default: '0'
type: string
enforce_delta:
description: 'Build fails when Δ MB exceeds threshold'
required: false
default: false
type: boolean
enforce_cap:
description: 'Build fails when size MB exceeds cap'
required: false
default: false
type: boolean
workflow_call:
inputs:
profile:
required: true
type: string
default: 'none'
compression:
required: false
type: string
default: 'LZ4HC'
clean_build:
required: true
default: true
type: boolean
cache_strategy:
required: true
default: 'library'
type: string
version:
required: true
type: string
sentry_enabled:
required: false
type: boolean
default: false
is_release_build:
type: boolean
required: false
default: false
install_source:
required: false
default: 'launcher'
type: string
tag_version:
type: string
required: false
delta_threshold_macos_mb:
description: 'Warn if macOS growth > this MB (0 = off)'
required: false
default: '0'
type: string
delta_threshold_windows_mb:
description: 'Warn if Windows growth > this MB (0 = off)'
required: false
default: '0'
type: string
enforce_delta:
description: 'Build fails when Δ MB exceeds threshold'
required: false
default: false
type: boolean
enforce_cap:
description: 'Build fails when size MB exceeds cap'
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.install_source }}
cancel-in-progress: >-
${{
github.event_name != 'pull_request' ||
github.event.action != 'labeled' ||
github.event.label.name == 'force-build' ||
github.event.label.name == 'clean-build'
}}
jobs:
prebuild:
name: Prebuild
runs-on: ubuntu-latest
timeout-minutes: 10
# Skip when PR has 'perf_test' label (only performance tests should run)
if: |
!contains(github.event.pull_request.labels.*.name, 'perf_test') && (
(github.ref == 'refs/heads/dev') ||
(github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch') ||
(
github.event_name == 'pull_request' &&
(
(
(github.event.action == 'opened' ||
github.event.action == 'reopened' ||
github.event.action == 'synchronize') &&
!github.event.pull_request.draft
) ||
github.event.action == 'ready_for_review' ||
(
github.event.action == 'labeled' &&
(github.event.label.name == 'force-build' || github.event.label.name == 'clean-build')
)
)
)
)
outputs:
commit_sha: ${{ steps.get_commit_sha.outputs.commit_sha }}
options: ${{ steps.get_options.outputs.options }}
version: ${{ github.event.inputs.version || inputs.version || steps.get_version.outputs.full_version }}
sentry_environment: ${{ steps.get_sentry.outputs.environment }}
sentry_upload_symbols: ${{ steps.get_sentry.outputs.upload_symbols }}
sentry_enabled: ${{ steps.get_sentry.outputs.sentry_enabled }}
clean_build: ${{ steps.set_defaults.outputs.clean_build }}
cache_strategy: ${{ steps.set_defaults.outputs.cache_strategy }}
install_source: ${{ steps.set_defaults.outputs.install_source }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changes under Explorer/**
id: changed_explorer
uses: step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
with:
files: |
Explorer/**
- name: Decide whether to build
id: decide
shell: bash
run: |
set -euo pipefail
# Non-PR triggers that reached prebuild => build
echo "[check non-PR] event_name='${{ github.event_name }}' != 'pull_request'"
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "[non-PR] TRUE -> should_build=true -> exiting 0"
exit 0
fi
labels="${{ join(github.event.pull_request.labels.*.name, ' ') }}"
echo "labels='$labels'"
has_override=false
echo "[check override] searching for 'force-build|clean-build' in labels"
echo "$labels" | grep -qwE 'force-build|clean-build' && has_override=true
echo "has_override='$has_override'"
if [ "$has_override" = "true" ]; then
echo "[override] TRUE -> should_build=true -> exiting 0"
exit 0
fi
# If still draft and no override => do not build
is_draft="${{ github.event.pull_request.draft }}"
echo "[check draft] is_draft='$is_draft'"
if [ "$is_draft" = "true" ]; then
echo "[draft] TRUE -> should_build=false -> exiting 1"
exit 1
fi
explorer_changed="${{ steps.changed_explorer.outputs.any_changed }}"
echo "[check explorer_changed] explorer_changed='$explorer_changed'"
if [ "$explorer_changed" = "true" ]; then
echo "[explorer_changed] TRUE -> should_build=true -> exiting 0"
exit 0
fi
echo "[explorer_changed] FALSE -> should_build=false -> exiting 1"
exit 1
- name: Get commit SHA
id: get_commit_sha
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "commit_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
else
echo "commit_sha=$GITHUB_SHA" >> $GITHUB_OUTPUT
fi
- name: Debug Commit SHA
run: |
echo "Ref from Pull Request: ${{ github.event.pull_request.head.sha }}"
echo "Full Commit from git rev-parse: $(git rev-parse $GITHUB_SHA)"
echo "HEAD Commit: $(git rev-parse HEAD)"
- name: Get version
id: get_version
if: ${{ github.event.inputs.version == '' && inputs.version == '' }}
uses: ./.github/actions/version
with:
commit_sha: ${{ steps.get_commit_sha.outputs.commit_sha }}
- name: Get Sentry parameters
id: get_sentry
run: |
#!/bin/bash
if [[ "${{ github.event.inputs.sentry_enabled || inputs.sentry_enabled }}" == "true" ]]; then
if [[ "${{ inputs.is_release_build }}" == "true" ]]; then
echo "environment=production" >> "$GITHUB_OUTPUT"
else
echo "environment=development" >> "$GITHUB_OUTPUT"
fi
echo "upload_symbols=true" >> "$GITHUB_OUTPUT"
echo "sentry_enabled=true" >> "$GITHUB_OUTPUT"
else
echo "environment=" >> "$GITHUB_OUTPUT"
echo "upload_symbols=false" >> "$GITHUB_OUTPUT"
echo "sentry_enabled=false" >> "$GITHUB_OUTPUT"
fi
- name: Set default values
id: set_defaults
run: |
# Clean build logic
if [ "${{ github.event.inputs.clean_build }}" ]; then
clean_build=${{ github.event.inputs.clean_build }}
elif [ "${{ inputs.clean_build }}" ]; then
clean_build=${{ inputs.clean_build }}
else
clean_build=false
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Checking PR labels: ${{ join(github.event.pull_request.labels.*.name, ', ') }}"
# Proper label check with spaces
clean_build=$(echo "${{ join(github.event.pull_request.labels.*.name, ' ') }}" | grep -qw 'clean-build' && echo true || echo false)
fi
fi
echo "Set clean_build to: $clean_build"
echo "clean_build=${clean_build}" >> $GITHUB_OUTPUT
if [ "${{ github.event.inputs.cache_strategy }}" ]; then
cache_strategy=${{ github.event.inputs.cache_strategy }}
elif [ "${{ inputs.cache_strategy }}" ]; then
cache_strategy=${{ inputs.cache_strategy }}
else
cache_strategy='library'
fi
echo "Set cache_strategy to: $cache_strategy"
echo "cache_strategy=${cache_strategy}" >> $GITHUB_OUTPUT
if [ "${{ github.event.inputs.install_source }}" ]; then
install_source=${{ github.event.inputs.install_source }}
elif [ "${{ inputs.install_source }}" ]; then
install_source=${{ inputs.install_source }}
else
install_source='launcher'
fi
echo "Set install_source to: $install_source"
echo "install_source=${install_source}" >> $GITHUB_OUTPUT
- name: Get BuildOptions
id: get_options
run: |
#!/bin/bash
#options=("DetailedBuildReport")
options=()
# compression - default is LZ4HC
compression="${{ github.event.inputs.compression || inputs.compression || 'LZ4HC' }}"
if [[ "$compression" == "LZ4" ]]; then
options+=("CompressWithLz4")
elif [[ "$compression" == "LZ4HC" ]]; then
options+=("CompressWithLz4HC")
fi
# input.profile
profile="${{ github.event.inputs.profile || inputs.profile }}"
if [[ "$profile" == "profile" || "$profile" == "deep" ]]; then
options+=("Development")
options+=("ConnectWithProfiler")
fi
if [[ "$profile" == "deep" ]]; then
options+=("EnableDeepProfilingSupport")
fi
# Write the array as a comma-separated string
# Set the Internal Field Separator to comma
IFS=,
echo "options=${options[*]}" | tee -a "$GITHUB_OUTPUT"
build:
name: Build
runs-on: ubuntu-latest
needs: prebuild
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
target: ['windows64', 'macos']
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.12.3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/cloudbuild/requirements.txt
- name: Execute Unity Cloud build
uses: nick-fields/retry@v3
with:
timeout_minutes: 180 # matches your GLOBAL_TIMEOUT = 10800s
max_attempts: 2
retry_on_exit_code: 99
retry_wait_seconds: 30
on_retry_command: |
echo "::warning::🔁 Unity Cloud Build retry triggered at $(date '+%Y-%m-%d %H:%M:%S')"
command: |
echo "🔧 Starting Unity Cloud Build attempt at $(date '+%Y-%m-%d %H:%M:%S')"
python -u scripts/cloudbuild/build.py
env:
API_KEY: ${{ secrets.UNITY_CLOUD_API_KEY }}
ORG_ID: ${{ secrets.UNITY_CLOUD_ORG_ID }}
PROJECT_ID: ${{ secrets.UNITY_CLOUD_PROJECT_ID }}
POLL_TIME: 60 # Set the polling time in seconds
GLOBAL_TIMEOUT: 10800 # Set the global timeout in seconds (e.g., 3 hours)
TARGET: t_${{ matrix.target }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
COMMIT_SHA: ${{ needs.prebuild.outputs.commit_sha }}
BUILD_OPTIONS: ${{ needs.prebuild.outputs.options }}
CLEAN_BUILD: ${{ needs.prebuild.outputs.clean_build }}
CACHE_STRATEGY: ${{ needs.prebuild.outputs.cache_strategy }}
IS_RELEASE_BUILD: ${{ inputs.is_release_build }}
TAG_VERSION: ${{ inputs.tag_version }}
#Possible values: { none, library, workspace, inherit }
# Any ENV variables starting with "PARAM_" will be passed to Unity without the prefix
# (The "PARAM_" prefix exists to allow any future values config-free)
# e.g.: PARAM_ALLOW_DEBUG -> In Unity will be available as "ALLOW_DEBUG"
# e.g.: Editor.CloudBuild.Parameters["ALLOW_DEBUG"]
PARAM_BUILD_VERSION: ${{ needs.prebuild.outputs.version }}
# solves https://github.com/decentraland/unity-explorer/issues/6789
# use pre-defined sentry dsn, but in case it is not defined, use the development sentry project
PARAM_SENTRY_DSN: ${{ inputs.is_release_build && secrets.SENTRY_DSN || secrets.SENTRY_DSN_DEV }}
PARAM_SENTRY_ENVIRONMENT: ${{ needs.prebuild.outputs.sentry_environment }}
PARAM_SENTRY_ENABLED: ${{ needs.prebuild.outputs.sentry_enabled }}
PARAM_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
PARAM_INSTALL_SOURCE: ${{ needs.prebuild.outputs.install_source }}
PARAM_IS_RELEASE_BUILD: ${{ inputs.is_release_build }}
PARAM_UNITY_EXTRA_PARAMS: '-disable-assembly-updater'
- name: 'Tar artifact to maintain original permissions'
if: matrix.target == 'macos'
run: tar --exclude='build/Decentraland_BackUpThisFolder_ButDontShipItWithYourGame' -cvf build.tar build
- name: Set artifact name
id: set_artifact_name
run: |
if [ "${{ needs.prebuild.outputs.install_source }}" == "launcher" ]; then
echo "artifact_name=Decentraland_${{ matrix.target }}" >> $GITHUB_ENV
else
echo "artifact_name=Decentraland_${{ matrix.target }}_${{ needs.prebuild.outputs.install_source }}" >> $GITHUB_ENV
fi
- name: Upload artifact for macOS
id: upload-macos-artifact
if: matrix.target == 'macos'
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: build.tar
if-no-files-found: error
- name: Upload artifact for Windows
id: upload-windows-artifact
if: matrix.target == 'windows64'
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}
path: |
build
!build/**/*_BackUpThisFolder_ButDontShipItWithYourGame
!build/**/*_BurstDebugInformation_DoNotShip
if-no-files-found: error
- name: Compress the build folder to upload it to S3
run: |
mkdir upload_to_s3/ && \
if [ "${{ matrix.target }}" == "macos" ]; then
zip -r upload_to_s3/${{ env.artifact_name }}.zip build.tar
elif [ "${{ matrix.target }}" == "windows64" ]; then
cd build
zip -r ../upload_to_s3/${{ env.artifact_name }}.zip . -x "*_BackUpThisFolder_ButDontShipItWithYourGame**" -x "*_BurstDebugInformation_DoNotShip**"
fi
- name: Install jq
run: sudo apt-get update -y && sudo apt-get install -y jq
- name: Enforce artifact size budget
id: size_check
env:
# Per-target absolute caps (MB)
MAX_MACOS_MB: 450
MAX_WINDOWS64_MB: 360
# Per-platform delta thresholds (MB); 0 = disabled
DELTA_MACOS_MB: ${{ github.event.inputs.delta_threshold_macos_mb || inputs.delta_threshold_macos_mb || '0' }}
DELTA_WINDOWS_MB: ${{ github.event.inputs.delta_threshold_windows_mb || inputs.delta_threshold_windows_mb || '0' }}
# Enforcement toggles (when true => FAIL build)
ENFORCE_DELTA: ${{ github.event.inputs.enforce_delta || inputs.enforce_delta || false }}
ENFORCE_CAP: ${{ github.event.inputs.enforce_cap || inputs.enforce_cap || false }}
REPO_FULL: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
FILE="upload_to_s3/${{ env.artifact_name }}.zip"
if [ ! -f "$FILE" ]; then
echo "::error::Artifact zip not found: $FILE"
exit 1
fi
# Current size in bytes
BYTES=$(stat -c%s "$FILE" 2>/dev/null || stat -f%z "$FILE")
# Convert to MB (decimal, 1 MB = 1,000,000) and MiB (binary, 1 MiB = 1,048,576)
MB_DEC=$(awk -v b="$BYTES" 'BEGIN { printf("%.1f", b/1000000) }')
MIB_BIN=$(awk -v b="$BYTES" 'BEGIN { printf("%.1f", b/1048576) }')
# Per-platform caps and delta thresholds
case "${{ matrix.target }}" in
macos) MAX=$MAX_MACOS_MB ; MAX_DELTA_MB=$DELTA_MACOS_MB ;;
windows64) MAX=$MAX_WINDOWS64_MB; MAX_DELTA_MB=$DELTA_WINDOWS_MB ;;
*) MAX=0; MAX_DELTA_MB=0 ;;
esac
echo "Checking ${{ matrix.target }} → ${MB_DEC} MB / ${MIB_BIN} MiB (cap ${MAX} MB, delta threshold ${MAX_DELTA_MB} MB)"
# Lookup latest release tag from GitHub API
API_LATEST="https://api.github.com/repos/${REPO_FULL}/releases/latest"
RELEASE_JSON=$(curl -sSL -H "Authorization: Bearer $GITHUB_TOKEN" "$API_LATEST")
RELEASE_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')
LATEST_FOUND=false
if [ -n "$RELEASE_TAG" ]; then
REPO_NAME="${REPO_FULL#*/}"
LATEST_NAME="${{ env.artifact_name }}.zip"
S3_URL="https://explorer-artifacts.decentraland.org/@dcl/${REPO_NAME}/releases/${RELEASE_TAG}/${LATEST_NAME}"
CL=$(curl -sI "$S3_URL" | awk '/[Cc]ontent-[Ll]ength:/ {print $2}' | tr -d '\r')
if [ -n "$CL" ]; then
MB_LATEST=$(( (CL + 999999) / 1000000 ))
MIB_LATEST=$(awk -v b="$CL" 'BEGIN { printf("%.1f", b/1048576) }')
LATEST_FOUND=true
echo "Latest release: ${RELEASE_TAG} → ${MB_LATEST} MB / ${MIB_LATEST} MiB"
fi
fi
# Delta
DELTA_MB="N/A"; DELTA_PCT="N/A"
if $LATEST_FOUND; then
DELTA_MB=$(awk -v cur="$MB_DEC" -v base="$MB_LATEST" 'BEGIN { printf("%d", cur - base) }')
DELTA_PCT=$(awk -v cur="$MB_DEC" -v base="$MB_LATEST" 'BEGIN { if (base==0){print "N/A"} else {printf("%.2f%%",(cur-base)*100.0/base)} }')
fi
# Flags
CAP_EXCEEDED=false
DELTA_EXCEEDED=false
if [ "${MAX:-0}" -gt 0 ] && (( $(echo "$MB_DEC > $MAX" | bc -l) )); then
CAP_EXCEEDED=true
[ "${ENFORCE_CAP}" = "true" ] && echo "::error::Artifact exceeds cap" || echo "::warning::Artifact exceeds cap"
fi
if $LATEST_FOUND && [ "${MAX_DELTA_MB:-0}" -gt 0 ]; then
ABS_DELTA_MB=${DELTA_MB#-}
if [ "$ABS_DELTA_MB" -gt "$MAX_DELTA_MB" ]; then
DELTA_EXCEEDED=true
[ "${ENFORCE_DELTA}" = "true" ] && echo "::error::Δ ${DELTA_MB} MB vs latest release exceeds threshold" || echo "::warning::Δ ${DELTA_MB} MB vs latest release exceeds threshold"
fi
fi
# Summary
{
echo "### Artifact size check (vs latest release)"
echo "_All sizes shown in both decimal MB (1 MB = 1,000,000 bytes) and binary MiB (1 MiB = 1,048,576 bytes)._"
echo
echo "| Target | File | Size (MB / MiB) | Cap (MB) | Δ MB vs latest release | Δ % vs latest release | Δ threshold (MB) | Result |"
echo "|---|---|---:|---:|---:|---:|---:|---|"
RESULT="✅ OK"
if [ "$CAP_EXCEEDED" = true ] || [ "$DELTA_EXCEEDED" = true ]; then
if [ "$CAP_EXCEEDED" = true ] && [ "$DELTA_EXCEEDED" = true ]; then
RESULT="❌ CAP & DELTA EXCEEDED"
elif [ "$CAP_EXCEEDED" = true ]; then
RESULT="❌ CAP EXCEEDED"
else
RESULT="❌ DELTA EXCEEDED"
fi
fi
if $LATEST_FOUND; then
echo "| ${{ matrix.target }} | \`$FILE\` | ${MB_DEC} / ${MIB_BIN} | ${MAX:-0} | $DELTA_MB | $DELTA_PCT | ${MAX_DELTA_MB:-0} | ${RESULT} |"
echo
echo "- Latest release: **${RELEASE_TAG}** (${MB_LATEST} MB / ${MIB_LATEST} MiB)"
else
echo "| ${{ matrix.target }} | \`$FILE\` | ${MB_DEC} / ${MIB_BIN} | ${MAX:-0} | N/A | N/A | ${MAX_DELTA_MB:-0} | ${RESULT} |"
fi
} >> "$GITHUB_STEP_SUMMARY"
# Export key values so the PR comment workflow can include them
echo "size_mb=$MB_DEC" >> "$GITHUB_OUTPUT"
echo "size_mib=$MIB_BIN" >> "$GITHUB_OUTPUT"
echo "cap_mb=${MAX:-0}" >> "$GITHUB_OUTPUT"
echo "delta_mb=$DELTA_MB" >> "$GITHUB_OUTPUT"
echo "delta_pct=$DELTA_PCT" >> "$GITHUB_OUTPUT"
echo "release_tag=${RELEASE_TAG:-}" >> "$GITHUB_OUTPUT"
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
# Enforce (fail the job) only if toggles are true
if [ "$CAP_EXCEEDED" = true ] && [ "${ENFORCE_CAP}" = "true" ]; then exit 1; fi
if [ "$DELTA_EXCEEDED" = true ] && [ "${ENFORCE_DELTA}" = "true" ]; then exit 1; fi
- name: Save size report
if: always() && steps.size_check.outputs.result != ''
run: |
mkdir -p size_report
{
echo "release_tag=${{ steps.size_check.outputs.release_tag }}"
echo "| ${{ matrix.target }} | ${{ steps.size_check.outputs.size_mb }} / ${{ steps.size_check.outputs.size_mib }} | ${{ steps.size_check.outputs.cap_mb }} | ${{ steps.size_check.outputs.delta_mb }} | ${{ steps.size_check.outputs.delta_pct }} | ${{ steps.size_check.outputs.result }} |"
} > size_report/size_report_${{ matrix.target }}.md
- name: Upload size report
if: always() && steps.size_check.outputs.result != ''
uses: actions/upload-artifact@v4
with:
name: size_report_${{ matrix.target }}_${{ needs.prebuild.outputs.install_source }}
path: size_report/
if-no-files-found: warn
- name: Set SHA, branch, and build prefix
run: |
echo "SHA_SHORT=$(echo ${{ needs.prebuild.outputs.commit_sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "SAFE_BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" >> $GITHUB_ENV
EVENT_NAME="${{ github.event_name }}"
echo "Detected event: $EVENT_NAME"
case "$EVENT_NAME" in
pull_request) echo "BUILD_PREFIX=pr" >> $GITHUB_ENV ;;
push) echo "BUILD_PREFIX=pu" >> $GITHUB_ENV ;;
merge_group) echo "BUILD_PREFIX=mg" >> $GITHUB_ENV ;;
workflow_dispatch) echo "BUILD_PREFIX=wd" >> $GITHUB_ENV ;;
workflow_call) echo "BUILD_PREFIX=wc" >> $GITHUB_ENV ;;
schedule) echo "BUILD_PREFIX=sc" >> $GITHUB_ENV ;;
*) echo "BUILD_PREFIX=gn" >> $GITHUB_ENV ;;
esac
- name: Upload artifact to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.EXPLORER_TEAM_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.EXPLORER_TEAM_AWS_SECRET_ACCESS_KEY }}
EXPLORER_TEAM_S3_BUCKET: ${{ secrets.EXPLORER_TEAM_S3_BUCKET }}
DESTINATION_PATH: "${{
inputs.is_release_build && format('@dcl/{0}/releases/{1}', github.event.repository.name, inputs.tag_version)
|| format('@dcl/{0}/branch/{1}/{2}-{3}-{4}', github.event.repository.name, env.SAFE_BRANCH_NAME, env.BUILD_PREFIX, github.run_number, env.SHA_SHORT)
}}"
run: |
npx @dcl/cdn-uploader@next \
--bucket $EXPLORER_TEAM_S3_BUCKET \
--local-folder upload_to_s3 \
--bucket-folder $DESTINATION_PATH
- name: Upload debug symbols
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact_name }}_debug_symbols
path: |
build/**/*_BackUpThisFolder_ButDontShipItWithYourGame
build/**/*_BurstDebugInformation_DoNotShip
if-no-files-found: error
- name: Upload debug symbols to Sentry
if: ${{ needs.prebuild.outputs.sentry_enabled == 'true' }}
shell: bash
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_CLI_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ inputs.is_release_build && vars.SENTRY_PROJECT || vars.SENTRY_PROJECT_DEV }}
run: |
npx --yes @sentry/cli debug-files upload \
--org "$SENTRY_ORG" \
--project "$SENTRY_PROJECT" \
"build"
# Will run always (even if failing)
- name: Upload cloud logs
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}_${{ needs.prebuild.outputs.install_source }}_unity_log
path: unity_cloud_log.log
if-no-files-found: error
# Will run always (even if failing)
- name: Print cloud logs
if: always()
run: cat unity_cloud_log.log
- name: Extract and display errors
if: always()
run: |
echo "=== Extracted Errors for ${{ matrix.target }} ${{ needs.prebuild.outputs.install_source }} ==="
grep -iE "error c|fatal" unity_cloud_log.log | sed 's/^/\x1b[31m/' | sed 's/$/\x1b[0m/' || echo "No 'error c' or 'fatal' errors found in ${{ matrix.target }} log."
- name: Generate Shader Compilation Report
shell: pwsh
run: |
./scripts/Generate-ShaderReport.ps1 -InputLog "unity_cloud_log.log" -OutputReport "shader_compilation_report.log"
- name: Upload Shader Compilation Report
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}_${{ needs.prebuild.outputs.install_source }}_shader_compilation_report
path: shader_compilation_report.log
if-no-files-found: warn
# Will run on cancel or timeout only
- name: Cancel Unity Cloud build
if: ${{ cancelled() }}
env:
API_KEY: ${{ secrets.UNITY_CLOUD_API_KEY }}
ORG_ID: ${{ secrets.UNITY_CLOUD_ORG_ID }}
PROJECT_ID: ${{ secrets.UNITY_CLOUD_PROJECT_ID }}
run: python -u scripts/cloudbuild/build.py --cancel