1
1
#! /bin/false
2
2
# shellcheck shell=bash
3
- # shellcheck disable=SC2154
4
-
5
- trap_build_script_exit () {
6
- exit_status=" $? "
7
-
8
- # The build script has a "set -x" on it. This will disable it for the rest of the run.
9
- set +x
10
-
11
- if [ " $exit_status " -ne 0 ]; then
12
- printf ' %s\n' ' The script did not complete successfully.'
13
- printf ' %s\n' " The exit code was $exit_status "
14
- exit " $exit_status "
15
- fi
16
-
17
- if [ " $PARAM_COMPRESS " -eq 1 ]; then
18
- printf ' %s\n' ' Compressing build artifacts...'
19
-
20
- # Compress artifacts to store them in the artifacts bucket.
21
- tar -czf " $base_dir /$PARAM_BUILD_TARGET .tar.gz" -C " $unity_project_full_path /Builds/$PARAM_BUILD_TARGET " .
22
- fi
23
- }
24
-
25
- # Download build script.
26
- curl --silent --location \
27
- --request GET \
28
- --url " https://gitlab.com/game-ci/unity3d-gitlab-ci-example/-/raw/main/ci/build.sh" \
29
- --header ' Accept: application/vnd.github.v3+json' \
30
- --output " $base_dir /build.sh"
31
-
32
- chmod +x " $base_dir /build.sh"
33
-
34
- # Name variables as required by the "build.sh" script.
35
- readonly BUILD_NAME=" $PARAM_BUILD_NAME "
36
- readonly BUILD_TARGET=" $PARAM_BUILD_TARGET "
37
- readonly UNITY_DIR=" $unity_project_full_path "
38
-
39
- export BUILD_NAME
40
- export BUILD_TARGET
41
- export UNITY_DIR
42
-
43
- # Trap "build.sh" exit otherwise it won't be possible to zip the artifacts.
44
- trap trap_build_script_exit EXIT
45
-
46
- # Run the build script.
47
- # shellcheck source=/dev/null
48
- source " $base_dir /build.sh"
3
+ # shellcheck disable=SC2048,SC2154,SC2086
4
+
5
+ readonly build_path=" $unity_project_full_path /Builds/$PARAM_BUILD_TARGET /"
6
+ mkdir -p " $build_path "
7
+
8
+ set -x
9
+ ${UNITY_EXECUTABLE:- xvfb-run --auto-servernum --server-args=' -screen 0 640x480x24' unity-editor} \
10
+ -projectPath " $unity_project_full_path " \
11
+ -quit \
12
+ -batchmode \
13
+ -nographics \
14
+ -buildTarget " $PARAM_BUILD_TARGET " \
15
+ -customBuildTarget " $PARAM_BUILD_TARGET " \
16
+ -customBuildName " $PARAM_BUILD_NAME " \
17
+ -customBuildPath " $build_path " \
18
+ -executeMethod " $build_method " \
19
+ -logFile /dev/stdout \
20
+ $custom_parameters # Needs to be unquoted. Otherwise it will be treated as a single parameter.
21
+ set +x
22
+
23
+ if [ " $PARAM_COMPRESS " -eq 1 ]; then
24
+ printf ' %s\n' ' Compressing build artifacts...'
25
+
26
+ # Compress artifacts to store them in the artifacts bucket.
27
+ tar -czf " $base_dir /$PARAM_BUILD_TARGET .tar.gz" -C " $build_path " .
28
+ fi
0 commit comments