diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index c213b9d..2c82b3b 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -328,6 +328,25 @@ workflows: filters: *filters context: orb-testing-unity pre-steps: *custom-build-method + - unity/build: + name: "build-with-custom-method-linux" + step-name: "Build with custom method in Linux" + unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" + unity-username-var-name: "UNITY_USERNAME" + unity-password-var-name: "UNITY_PASSWORD" + executor: + name: "unity/ubuntu" + target_platform: "linux-il2cpp" + editor_version: "2021.3.1f1" + resource_class: "large" + project-path: "Unity2D-Demo-Game-CI-CD/src" + build-target: StandaloneLinux64 + build-method: "MyCustomBuildCommand.MyCustomBuildMethod" + custom-parameters: "-customParam1 potato -customParam2 tomato -customParam3 $CIRCLE_WORKFLOW_ID -DetailedBuildReport" + compress: true + filters: *filters + context: orb-testing-unity + pre-steps: *custom-build-method - orb-tools/pack: filters: *filters @@ -353,6 +372,7 @@ workflows: - build-without-artifacts - build-with-custom-method-windows - build-with-custom-method-osx + - build-with-custom-method-linux context: orb-publishing filters: branches: diff --git a/src/scripts/linux/build.sh b/src/scripts/linux/build.sh index 197eba9..147acb8 100644 --- a/src/scripts/linux/build.sh +++ b/src/scripts/linux/build.sh @@ -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" \ No newline at end of file +# 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