From 5c1d84357d8553897625c52329ffebbb7fb223ac Mon Sep 17 00:00:00 2001 From: Webber Date: Tue, 7 Jan 2020 23:19:23 +0100 Subject: [PATCH] Add activation step --- builder/Dockerfile | 2 + builder/entrypoint.sh | 6 +++ builder/steps/activate.sh | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 builder/steps/activate.sh diff --git a/builder/Dockerfile b/builder/Dockerfile index 59be746d..8392281b 100644 --- a/builder/Dockerfile +++ b/builder/Dockerfile @@ -11,6 +11,8 @@ LABEL "homepage"="http://github.com/webbertakken/unity-actions" LABEL "maintainer"="Webber Takken " ADD default-build-script /UnityBuilderAction +ADD steps /steps +RUN chmod -R +x /steps ADD entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/builder/entrypoint.sh b/builder/entrypoint.sh index 2330355a..bd5a3c6f 100644 --- a/builder/entrypoint.sh +++ b/builder/entrypoint.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +# +# +# + +/steps/activate.sh + # # Set project path # diff --git a/builder/steps/activate.sh b/builder/steps/activate.sh new file mode 100644 index 00000000..0e114864 --- /dev/null +++ b/builder/steps/activate.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +if [[ -n "$UNITY_LICENSE" ]]; then + # + # PERSONAL LICENSE MODE + # + # This will activate Unity, using a license file + # + # Note that this is the ONLY WAY for PERSONAL LICENSES in 2019. + # * See for more details: https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/5#note_72815478 + # + # The license file can be acquired using `webbertakken/request-manual-activation-file` action. + + # Set the license file path + FILE_PATH=UnityLicenseFile.ulf + + # Copy license file from Github variables + echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH + + ## + ## Activate license + ## + echo "Requesting activation" + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity \ + -batchmode \ + -nographics \ + -logFile /dev/stdout \ + -quit \ + -manualLicenseFile $FILE_PATH + # This is expected to always exit with code 1 (both success and failure). + # Convert to exit code 0 by echoing the current exit code. + echo $? + # Exit code is now 0 + + # TODO - Derive exit code by grepping success statement + UNITY_EXIT_CODE=0 + + # Display information about the result + if [ $UNITY_EXIT_CODE -eq 0 ]; then + echo "Activation (personal) complete." + else + echo "Unclassified error occured while trying to activate (personal) license." + echo "Exit code was: $UNITY_EXIT_CODE" + fi + + # Remove license file + rm -f $FILE_PATH + + # Exit with the code from the license verification step + exit $UNITY_EXIT_CODE + +else + # + # PROFESSIONAL (SERIAL) LICENSE MODE + # + # This will activate unity, using the activating process. + # + # Note: This is the preferred way for PROFESSIONAL LICENSES. + # + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' \ + /opt/Unity/Editor/Unity \ + -batchmode \ + -nographics \ + -logFile /dev/stdout \ + -quit \ + -serial "$UNITY_SERIAL" \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" + + # Store the exit code from the verify command + UNITY_EXIT_CODE=$? + + # Display information about the result + if [ $UNITY_EXIT_CODE -eq 0 ]; then + echo "Activation (professional) complete." + else + echo "Unclassified error occured while trying to activate (professional) license." + echo "Exit code was: $UNITY_EXIT_CODE" + fi + + # Exit with the code from the license verification step + exit $UNITY_EXIT_CODE + +fi