1
1
#! /bin/false
2
2
# shellcheck shell=bash
3
- # shellcheck disable=SC2154
3
+ # shellcheck disable=SC2016, SC2154
4
4
5
5
trap_exit () {
6
6
local exit_status=" $? "
@@ -25,13 +25,34 @@ docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVa
25
25
docker exec " $CONTAINER_NAME " powershell " [System.Environment]::SetEnvironmentVariable('BUILD_METHOD','$build_method ', [System.EnvironmentVariableTarget]::Machine)"
26
26
docker exec " $CONTAINER_NAME " powershell " [System.Environment]::SetEnvironmentVariable('CUSTOM_PARAMS','$custom_parameters ', [System.EnvironmentVariableTarget]::Machine)"
27
27
28
+ build_args=(
29
+ ' -batchmode'
30
+ ' -quit'
31
+ ' -nographics'
32
+ ' -projectPath $Env:PROJECT_PATH'
33
+ ' -buildTarget $Env:BUILD_TARGET'
34
+ ' -customBuildTarget $Env:BUILD_TARGET'
35
+ ' -customBuildName $Env:BUILD_NAME'
36
+ ' -customBuildPath "C:/build/"'
37
+ ' -executeMethod $Env:BUILD_METHOD'
38
+ )
39
+
40
+ [ -n " $custom_parameters " ] && build_args+=( ' $Env:CUSTOM_PARAMS.split()' )
41
+
28
42
# Build the project
29
43
# Versioning of the project needs work. This is how it's done in the GHA:
30
44
# https://github.com/game-ci/unity-builder/blob/main/src/model/versioning.ts
31
45
set -x
32
- docker exec " $CONTAINER_NAME " powershell ' & "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -projectPath $Env:PROJECT_PATH -buildTarget $Env:BUILD_TARGET -customBuildTarget $Env:BUILD_TARGET -customBuildName $Env:BUILD_NAME -customBuildPath "C:/build/" -executeMethod $Env:BUILD_METHOD $Env:CUSTOM_PARAMS.split() -logfile | Out-Host'
46
+ docker exec " $CONTAINER_NAME " powershell " & 'C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe' ${build_args[*]} -logfile | Out-Host"
47
+ exit_code=" $? "
33
48
set +x
34
49
50
+ if [ " $exit_code " -ne 0 ]; then
51
+ printf ' %s\n' " Failed to build the project."
52
+ printf ' %s\n' " Please try again, open an issue or reach out to us on Discord."
53
+ exit " $exit_code "
54
+ fi
55
+
35
56
# Compress the build folder.
36
57
docker exec " $CONTAINER_NAME " powershell ' tar -czf "C:/$Env:BUILD_NAME-$Env:BUILD_TARGET.tar.gz" -C "C:/build" .'
37
58
0 commit comments