-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: decouple Linux's
build
command from GitLab and introduce new …
…features (#37) * feat: decouple `build` from GitLab and add custom `executeMethod` * fix: artifacts compression * fix: add forward slash at the end of build path * refactor: add new line at the end of the file
- Loading branch information
1 parent
b737a31
commit a9489e1
Showing
2 changed files
with
46 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,28 @@ | ||
#!/bin/false | ||
# shellcheck shell=bash | ||
# shellcheck disable=SC2154 | ||
|
||
trap_build_script_exit() { | ||
exit_status="$?" | ||
|
||
# The build script has a "set -x" on it. This will disable it for the rest of the run. | ||
set +x | ||
|
||
if [ "$exit_status" -ne 0 ]; then | ||
printf '%s\n' 'The script did not complete successfully.' | ||
printf '%s\n' "The exit code was $exit_status" | ||
exit "$exit_status" | ||
fi | ||
|
||
if [ "$PARAM_COMPRESS" -eq 1 ]; then | ||
printf '%s\n' 'Compressing build artifacts...' | ||
|
||
# Compress artifacts to store them in the artifacts bucket. | ||
tar -czf "$base_dir/$PARAM_BUILD_TARGET.tar.gz" -C "$unity_project_full_path/Builds/$PARAM_BUILD_TARGET" . | ||
fi | ||
} | ||
|
||
# Download build script. | ||
curl --silent --location \ | ||
--request GET \ | ||
--url "https://gitlab.com/game-ci/unity3d-gitlab-ci-example/-/raw/main/ci/build.sh" \ | ||
--header 'Accept: application/vnd.github.v3+json' \ | ||
--output "$base_dir/build.sh" | ||
|
||
chmod +x "$base_dir/build.sh" | ||
|
||
# Name variables as required by the "build.sh" script. | ||
readonly BUILD_NAME="$PARAM_BUILD_NAME" | ||
readonly BUILD_TARGET="$PARAM_BUILD_TARGET" | ||
readonly UNITY_DIR="$unity_project_full_path" | ||
|
||
export BUILD_NAME | ||
export BUILD_TARGET | ||
export UNITY_DIR | ||
|
||
# Trap "build.sh" exit otherwise it won't be possible to zip the artifacts. | ||
trap trap_build_script_exit EXIT | ||
|
||
# Run the build script. | ||
# shellcheck source=/dev/null | ||
source "$base_dir/build.sh" | ||
# shellcheck disable=SC2048,SC2154,SC2086 | ||
|
||
readonly build_path="$unity_project_full_path/Builds/$PARAM_BUILD_TARGET/" | ||
mkdir -p "$build_path" | ||
|
||
set -x | ||
${UNITY_EXECUTABLE:-xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' unity-editor} \ | ||
-projectPath "$unity_project_full_path" \ | ||
-quit \ | ||
-batchmode \ | ||
-nographics \ | ||
-buildTarget "$PARAM_BUILD_TARGET" \ | ||
-customBuildTarget "$PARAM_BUILD_TARGET" \ | ||
-customBuildName "$PARAM_BUILD_NAME" \ | ||
-customBuildPath "$build_path" \ | ||
-executeMethod "$build_method" \ | ||
-logFile /dev/stdout \ | ||
$custom_parameters # Needs to be unquoted. Otherwise it will be treated as a single parameter. | ||
set +x | ||
|
||
if [ "$PARAM_COMPRESS" -eq 1 ]; then | ||
printf '%s\n' 'Compressing build artifacts...' | ||
|
||
# Compress artifacts to store them in the artifacts bucket. | ||
tar -czf "$base_dir/$PARAM_BUILD_TARGET.tar.gz" -C "$build_path" . | ||
fi |