-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-windows-git-bash.sh
executable file
·55 lines (41 loc) · 1.55 KB
/
build-windows-git-bash.sh
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
#!/usr/bin/env bash
# This script was adapted from https://gitlab.com/gableroux/unity3d-gitlab-ci-example/-/blob/896c8cae/ci/build.sh to work on Windows
set -ex
echo "Building for $BUILD_TARGET"
BUILD_MACHINE_USERNAME=Totema
WINDOWS_CURRENT_BUILD_PATH=$PWD
BUILD_PATH="$PWD/Builds/$BUILD_TARGET"
WINDOWS_BUILD_PATH=$BUILD_PATH
mkdir -p $BUILD_PATH || true
UNITY_LOG_PATH=/c/Users/$BUILD_MACHINE_USERNAME/AppData/Local/Unity/Editor/editor.log
# reset unity log on each build as a workaround
echo '' > $UNITY_LOG_PATH
set +e
"${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' /opt/Unity/Editor/Unity}" \
-projectPath "${WINDOWS_CURRENT_BUILD_PATH}" \
-quit \
-batchmode \
-buildTarget $BUILD_TARGET \
-customBuildTarget $BUILD_TARGET \
-customBuildName $BUILD_NAME \
-customBuildPath "${WINDOWS_BUILD_PATH}" \
-customBuildOptions AcceptExternalModificationsToPlayer \
-executeMethod BuildCommand.PerformBuild \
-logFile
UNITY_EXIT_CODE=$?
set -e
# read the unity log at and of build, this is the only way I managed to get output in the console and it's not very reliable
cat $UNITY_LOG_PATH
if [ $UNITY_EXIT_CODE -eq 0 ]; then
echo "Run succeeded, no failures occurred";
elif [ $UNITY_EXIT_CODE -eq 2 ]; then
echo "Run succeeded, some tests failed";
elif [ $UNITY_EXIT_CODE -eq 3 ]; then
echo "Run failure (other failure)";
else
echo "Unexpected exit code $UNITY_EXIT_CODE";
fi
ls -la $BUILD_PATH
[ -n "$(ls -A $BUILD_PATH)" ] # fail job if build folder is empty
BUILD_SCRIPT_EXIT_CODE=$?
exit $BUILD_SCRIPT_EXIT_CODE