From 889ddb3802294555400e6e291e2eb502a0ad80c8 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 21:40:34 -0500 Subject: [PATCH 01/10] Download and prepare before_script file from gitlab ref --- src/scripts/linux/prepare-env.sh | 37 ++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/scripts/linux/prepare-env.sh b/src/scripts/linux/prepare-env.sh index 274da0d..dfbbc86 100644 --- a/src/scripts/linux/prepare-env.sh +++ b/src/scripts/linux/prepare-env.sh @@ -42,7 +42,7 @@ resolve_unity_license() { fi else - printf '%s\n' "If you own a Personal Unity License File (.ulf), please provide it as a base64 encoded string." + printf '%s\n' "If you own a Personal Unity License File (.ulf), please provide it as a base64 encoded string." printf '%s\n' "If you own a Plus or Pro Unity license, please provide your username, password and serial." printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation" @@ -54,6 +54,25 @@ resolve_unity_license() { fi } +download_and_prepare_before_script() { + local repo_url="$1" + local ref="$2" + local file_path="$3" + local output_path="$4" + + # Construct the full URL + local full_url="$repo_url/-/raw/$ref/$file_path" + + # Use curl to download the file + curl --silent --location \ + --request GET \ + --url "$full_url" \ + --output "$output_path" + + # Make the script executable + chmod +x "$output_path" +} + # Check if serial or encoded license was provided. # If the latter, extract the serial from the license. if ! resolve_unity_license; then @@ -62,14 +81,14 @@ if ! resolve_unity_license; then exit 1 fi -# Download before_script.sh from GameCI. -curl --silent --location \ - --request GET \ - --url "https://gitlab.com/game-ci/unity3d-gitlab-ci-example/-/raw/main/ci/before_script.sh" \ - --header 'Accept: application/vnd.github.v3+json' \ - --output "$base_dir/before_script.sh" +# Define variables +repo_url="https://gitlab.com/game-ci/unity3d-gitlab-ci-example" +ref="e6ff757" # Will update to a tag once latest version is merged +file_path="ci/before_script.sh" +before_script="$base_dir/before_script.sh" -chmod +x "$base_dir/before_script.sh" +# Download and prepare the before_script file +download_and_prepare_before_script "$repo_url" "$ref" "$file_path" "$before_script" # Nomenclature required by the script. readonly UNITY_LICENSE="$unity_license" @@ -78,4 +97,4 @@ export UNITY_LICENSE # Run the test script. # shellcheck source=/dev/null -source "$base_dir/before_script.sh" \ No newline at end of file +source "$before_script" From e390dc8150fd0a529c17f4cbd20daf11dc154fb7 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 21:53:23 -0500 Subject: [PATCH 02/10] Update ref to "7fc1c95" in prepare-env.sh to get retry logic --- src/scripts/linux/prepare-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/linux/prepare-env.sh b/src/scripts/linux/prepare-env.sh index dfbbc86..a1bfbc2 100644 --- a/src/scripts/linux/prepare-env.sh +++ b/src/scripts/linux/prepare-env.sh @@ -83,7 +83,7 @@ fi # Define variables repo_url="https://gitlab.com/game-ci/unity3d-gitlab-ci-example" -ref="e6ff757" # Will update to a tag once latest version is merged +ref="7fc1c95" # Will update to a tag once latest version is merged file_path="ci/before_script.sh" before_script="$base_dir/before_script.sh" From bdecd65ae22e49bab5112a2f03fff510bd968596 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 22:40:14 -0500 Subject: [PATCH 03/10] Activate Unity with username, password, and serial --- .circleci/test-deploy.yml | 52 ++++----- src/commands/prepare-env.yml | 6 - src/commands/return-license.yml | 9 ++ .../test_and_build_personal_license.yml | 12 +- .../test_and_build_pro_or_plus_license.yml | 8 +- src/jobs/build.yml | 12 +- src/jobs/create-activation-file.yml | 23 ---- src/jobs/test.yml | 12 +- src/scripts/linux/prepare-env.sh | 104 ++++++++++-------- src/scripts/linux/return-license.sh | 3 +- src/scripts/macos/prepare-env.sh | 2 +- src/scripts/macos/return-license.sh | 3 +- 12 files changed, 115 insertions(+), 131 deletions(-) delete mode 100644 src/jobs/create-activation-file.yml diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 48ee65a..326deba 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -77,20 +77,13 @@ jobs: workflows: test-build: jobs: - # Activation file - - unity/create-activation-file: - name: "create-activation-file" - - unity/create-activation-file: - name: "create-activation-file-with-parameter" - editor_version: 2022.1.11f1 - # Tests - unity/test: name: "test-linux" step-name: "Check if the tests run and results are uploaded" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "linux-il2cpp" @@ -104,9 +97,9 @@ workflows: - unity/test: name: "test-linux-with-custom-parameters" step-name: "Check if test filter in custom parameter works" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "linux-il2cpp" @@ -121,9 +114,10 @@ workflows: # - unity/test: # name: "test-windows" # step-name: "Check if the tests run and results are uploaded" - # unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" # unity-username-var-name: "UNITY_USERNAME" # unity-password-var-name: "UNITY_PASSWORD" + # unity-serial-var-name: "UNITY_SERIAL" + # serial-password-var-name: "UNITY_SERIAL" # executor: # name: "unity/windows-2019" # size: "large" @@ -137,9 +131,9 @@ workflows: # - unity/test: # name: "test-windows-with-custom-parameters" # step-name: "Check if test filter in custom parameter works" - # unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" # unity-username-var-name: "UNITY_USERNAME" # unity-password-var-name: "UNITY_PASSWORD" + # unity-serial-var-name: "UNITY_SERIAL" # executor: # name: "unity/windows-2019" # size: "large" @@ -154,9 +148,9 @@ workflows: - unity/test: name: "test-osx" step-name: "Check if the tests run and results are uploaded" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/macos" editor_version: "2022.3.33f1" @@ -169,9 +163,9 @@ workflows: - unity/test: name: "test-osx-with-custom-parameters" step-name: "Check if test filter in custom parameter works" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/macos" editor_version: "2022.3.33f1" @@ -187,9 +181,9 @@ workflows: - unity/build: name: "build-linux64-il2cpp" step-name: "Build StandaloneLinux64" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "linux-il2cpp" @@ -204,9 +198,9 @@ workflows: # - unity/build: # name: "build-Windows64-il2cpp" # step-name: "Build StandaloneWindows64 il2cpp" - # unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" # unity-username-var-name: "UNITY_USERNAME" # unity-password-var-name: "UNITY_PASSWORD" + # unity-serial-var-name: "UNITY_SERIAL" # executor: # name: "unity/windows-2019" # size: "large" @@ -221,9 +215,9 @@ workflows: - unity/build: name: "build-osx-il2cpp" step-name: "Build macOS IL2CPP" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/macos" editor_version: "2022.3.33f1" @@ -239,9 +233,9 @@ workflows: - unity/build: name: "build-linux64-mono" step-name: "Build StandaloneLinux64" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "base" @@ -256,9 +250,9 @@ workflows: - unity/build: name: "build-Windows64-mono" step-name: "Build StandaloneWindows64" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "windows-mono" @@ -272,9 +266,9 @@ workflows: - unity/build: name: "build-osx-mono" step-name: "Build StandaloneOSX" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "mac-mono" @@ -290,9 +284,9 @@ workflows: - unity/build: name: "build-webgl" step-name: "Build WebGL" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "webgl" @@ -307,9 +301,9 @@ workflows: - unity/build: name: "build-android" step-name: "Build Android" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "android" @@ -323,9 +317,9 @@ workflows: - unity/build: name: "build-ios" step-name: "Build iOS" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "ios" @@ -339,9 +333,9 @@ workflows: # - unity/build: # name: "build-tvOS" # step-name: "Build Apple's tvOS" - # unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" # unity-username-var-name: "UNITY_USERNAME" # unity-password-var-name: "UNITY_PASSWORD" + # unity-serial-var-name: "UNITY_SERIAL" # executor: # name: "unity/windows-2019" # size: "large" @@ -358,9 +352,9 @@ workflows: - unity/build: name: "build-without-artifacts" step-name: "Build StandaloneLinux64 with no artifacts" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "base" @@ -375,9 +369,9 @@ workflows: # - unity/build: # name: "build-with-custom-method-windows" # step-name: "Build with custom method in Windows" - # unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" # unity-username-var-name: "UNITY_USERNAME" # unity-password-var-name: "UNITY_PASSWORD" + # unity-serial-var-name: "UNITY_SERIAL" # executor: # name: "unity/windows-2019" # size: "large" @@ -393,9 +387,9 @@ workflows: - unity/build: name: "build-with-custom-method-osx" step-name: "Build with custom method in macOS" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/macos" editor_version: "2022.3.33f1" @@ -410,9 +404,9 @@ workflows: - 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" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "linux-il2cpp" @@ -429,9 +423,9 @@ workflows: - unity/build: name: "build-with-workspace" step-name: "Build StandaloneLinux64 with workspace" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "base" @@ -450,9 +444,9 @@ workflows: - unity/build: name: "compress-build-with-workspace" step-name: "Compress build StandaloneLinux64 with workspace" - unity-license-var-name: "UNITY_ENCODED_LICENSE_2021" unity-username-var-name: "UNITY_USERNAME" unity-password-var-name: "UNITY_PASSWORD" + unity-serial-var-name: "UNITY_SERIAL" executor: name: "unity/ubuntu" target_platform: "base" diff --git a/src/commands/prepare-env.yml b/src/commands/prepare-env.yml index 32e7372..20dafa9 100644 --- a/src/commands/prepare-env.yml +++ b/src/commands/prepare-env.yml @@ -18,12 +18,6 @@ parameters: description: | Enter the name of the environment variable containing your Unity serial number. Required if you have a Plus or Pro license. - unity-license-var-name: - type: env_var_name - default: "UNITY_ENCODED_LICENSE" - description: | - Enter the name of the environment variable containing your Unity license file encoded in base64. - Required if you have a Personal license. cache-version: type: string default: "v1" diff --git a/src/commands/return-license.yml b/src/commands/return-license.yml index d6c2580..e73f20a 100644 --- a/src/commands/return-license.yml +++ b/src/commands/return-license.yml @@ -12,6 +12,15 @@ parameters: default: "UNITY_PASSWORD" description: | Enter the name of the environment variable containing your Unity password. + unity-serial-var-name: + type: env_var_name + default: "UNITY_SERIAL" + description: | + Enter the name of the environment variable containing your Unity serial number. + Required even for personal license. + TODO: Improve documentation on how to extract from personal license, it's something like this: + cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode + For future versions, we could simply request the user to provide the ulf file and we could do the extraction. steps: - run: diff --git a/src/examples/test_and_build_personal_license.yml b/src/examples/test_and_build_personal_license.yml index 8df4415..32a43be 100755 --- a/src/examples/test_and_build_personal_license.yml +++ b/src/examples/test_and_build_personal_license.yml @@ -17,9 +17,9 @@ usage: - unity/test: name: 'test-linux' step-name: 'Check if the tests run and results are uploaded' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/ubuntu' target_platform: 'linux-il2cpp' @@ -31,9 +31,9 @@ usage: - unity/build: name: 'build-linux64-il2cpp' step-name: 'Build StandaloneLinux64' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/ubuntu' target_platform: 'linux-il2cpp' @@ -49,9 +49,9 @@ usage: - unity/test: name: 'test-windows' step-name: 'Check if the tests run and results are uploaded' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/windows-2022' size: 'large' @@ -63,9 +63,9 @@ usage: - unity/build: name: 'build-Windows64-il2cpp' step-name: 'Build StandaloneWindows64 il2cpp' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/windows-2019' size: 'large' @@ -81,9 +81,9 @@ usage: - unity/test: name: 'test-osx' step-name: 'Check if the tests run and results are uploaded' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/macos' editor_version: '2022.3.33f1' @@ -94,9 +94,9 @@ usage: - unity/build: name: 'build-osx-il2cpp' step-name: 'Build macOS IL2CPP' - unity-license-var-name: 'UNITY_ENCODED_LICENSE' unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: 'UNITY_SERIAL' executor: name: 'unity/macos' resource_class: "macos.m1.medium.gen1" diff --git a/src/examples/test_and_build_pro_or_plus_license.yml b/src/examples/test_and_build_pro_or_plus_license.yml index 35465c3..5c27cfb 100755 --- a/src/examples/test_and_build_pro_or_plus_license.yml +++ b/src/examples/test_and_build_pro_or_plus_license.yml @@ -49,9 +49,9 @@ usage: - unity/test: name: 'test-windows' step-name: 'Check if the tests run and results are uploaded' - unity-serial-var-name: "UNITY_SERIAL" unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/windows-2022' size: 'large' @@ -63,9 +63,9 @@ usage: - unity/build: name: 'build-Windows64-il2cpp' step-name: 'Build StandaloneWindows64 il2cpp' - unity-serial-var-name: "UNITY_SERIAL" unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/windows-2019' size: 'large' @@ -81,9 +81,9 @@ usage: - unity/test: name: 'test-osx' step-name: 'Check if the tests run and results are uploaded' - unity-serial-var-name: "UNITY_SERIAL" unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/macos' editor_version: '2022.3.33f1' @@ -94,9 +94,9 @@ usage: - unity/build: name: 'build-osx-il2cpp' step-name: 'Build macOS IL2CPP' - unity-serial-var-name: "UNITY_SERIAL" unity-username-var-name: 'UNITY_USERNAME' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/macos' resource_class: "macos.m1.medium.gen1" diff --git a/src/jobs/build.yml b/src/jobs/build.yml index 9170c0f..6a336e2 100755 --- a/src/jobs/build.yml +++ b/src/jobs/build.yml @@ -26,13 +26,10 @@ parameters: default: "UNITY_SERIAL" description: | Enter the name of the environment variable containing your Unity serial number. - Required if you have a Plus or Pro license. - unity-license-var-name: - type: env_var_name - default: "UNITY_ENCODED_LICENSE" - description: | - Enter the name of the environment variable containing your Unity license file encoded in base64. - Required if you have a Personal license. + Required even for personal license. + TODO: Improve documentation on how to extract from personal license, it's something like this: + cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode + For future versions, we could simply request the user to provide the ulf file and we could do the extraction. project-path: type: string default: "." @@ -112,7 +109,6 @@ steps: unity-username-var-name: << parameters.unity-username-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> unity-serial-var-name: << parameters.unity-serial-var-name >> - unity-license-var-name: << parameters.unity-license-var-name >> project-path: <> no_output_timeout: << parameters.no_output_timeout>> - build: diff --git a/src/jobs/create-activation-file.yml b/src/jobs/create-activation-file.yml deleted file mode 100644 index b1455f0..0000000 --- a/src/jobs/create-activation-file.yml +++ /dev/null @@ -1,23 +0,0 @@ -description: > - Simple drop-in job to create a Unity activation file. - -parameters: - editor_version: - description: | - Pick the editor version for the GameCI image. - Available options can be found at https://game.ci/docs/docker/versions. - type: string - default: "2022.3.33f1" - -docker: - - image: 'unityci/editor:ubuntu-<>-base-3' - -resource_class: medium - -steps: - - checkout - - run: - name: Create Unity activation file - command: << include(scripts/linux/create-activation-file.sh) >> - - store_artifacts: - path: Unity.alf diff --git a/src/jobs/test.yml b/src/jobs/test.yml index 9a21adf..d5954ff 100644 --- a/src/jobs/test.yml +++ b/src/jobs/test.yml @@ -26,13 +26,10 @@ parameters: default: "UNITY_SERIAL" description: | Enter the name of the environment variable containing your Unity serial number. - Required if you have a Plus or Pro license. - unity-license-var-name: - type: env_var_name - default: "UNITY_ENCODED_LICENSE" - description: | - Enter the name of the environment variable containing your Unity license file encoded in base64. - Required if you have a Personal license. + Required even for personal license. + TODO: Improve documentation on how to extract from personal license, it's something like this: + cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode + For future versions, we could simply request the user to provide the ulf file and we could do the extraction. project-path: type: string default: "." @@ -73,7 +70,6 @@ steps: unity-username-var-name: << parameters.unity-username-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> unity-serial-var-name: << parameters.unity-serial-var-name >> - unity-license-var-name: << parameters.unity-license-var-name >> project-path: <> no_output_timeout: << parameters.no_output_timeout>> - test: diff --git a/src/scripts/linux/prepare-env.sh b/src/scripts/linux/prepare-env.sh index a1bfbc2..147708e 100644 --- a/src/scripts/linux/prepare-env.sh +++ b/src/scripts/linux/prepare-env.sh @@ -2,54 +2,70 @@ # shellcheck shell=bash # shellcheck disable=SC2154 -create_manual_activation_file() { - unity-editor \ - -batchmode \ - -nographics \ - -createManualActivationFile \ - -quit \ - -logfile /dev/null - - # Check if license file was created successfully. - if ls Unity_v*.alf &> /dev/null; then return 0; else return 1; fi -} - resolve_unity_license() { - if [ -n "$unity_encoded_license" ]; then - # Decode Personal Unity License File. - unity_license=$(printf '%s\n' "$unity_encoded_license" | base64 --decode) + if [ -n "$unity_username" ] && [ -n "$unity_password" ]; then + if [ -n "$unity_serial" ]; then + # Combination: username + email + serial + echo "Activating Unity with username, password, and serial." + unity-editor \ + -logFile /dev/stdout \ + -batchmode \ + -nographics \ + -quit \ + -username "$unity_username" \ + -password "$unity_password" \ + -serial "$unity_serial" + + validate_license_file || return 1 + + elif [ -n "$unity_encoded_license" ]; then + # Combination: username + email + encoded license file + echo "Activating Unity with username, password, and encoded license." + unity_license=$(printf '%s\n' "$unity_encoded_license" | base64 --decode) + + # Extract serial number from license + unity_serial=$(echo "$unity_license" | grep -oP '(?<=SerialNumber=).*') + if [ -z "$unity_serial" ]; then + echo "Failed to extract serial number from the encoded license file." + return 1 + fi + + unity-editor \ + -logFile /dev/stdout \ + -batchmode \ + -nographics \ + -quit \ + -username "$unity_username" \ + -password "$unity_password" \ + -serial "$unity_serial" + + validate_license_file || return 1 - elif [ -n "$unity_username" ] && [ -n "$unity_password" ] && [ -n "$unity_serial" ]; then - # Generate Plus or Pro Unity License File. - unity-editor \ - -logFile /dev/stdout \ - -batchmode \ - -nographics \ - -quit \ - -username "$unity_username" \ - -password "$unity_password" \ - -serial "$unity_serial" - - if [ -e "/root/.local/share/unity3d/Unity/Unity_lic.ulf" ]; then - unity_license="$(cat /root/.local/share/unity3d/Unity/Unity_lic.ulf)" else - printf '%s\n' "Failed to generate Unity license file." - printf '%s\n' "Make sure you have entered the correct username, password and serial and try again." - printf '%s\n' "If you are still having problems, please open an issue." - printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation#professional-license" - + echo "Missing serial or encoded license. Cannot activate Unity." return 1 fi - else - printf '%s\n' "If you own a Personal Unity License File (.ulf), please provide it as a base64 encoded string." - printf '%s\n' "If you own a Plus or Pro Unity license, please provide your username, password and serial." - printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation" + elif [ -n "$unity_encoded_license" ]; then + # Combination: encoded license file only + echo "Activating Unity with encoded license only." + unity_license=$(printf '%s\n' "$unity_encoded_license" | base64 --decode) + echo "$unity_license" > "/root/.local/share/unity3d/Unity/Unity_lic.ulf" - if create_manual_activation_file; then - printf '%s\n' "Should you require a new Personal Activation License File (.alf), rerun the job with SSH and you will find it at \"${base_dir}/$(ls Unity_v*)\"" - fi + validate_license_file || return 1 + else + echo "No valid activation combination provided." + return 1 + fi +} + +validate_license_file() { + if [ -e "/root/.local/share/unity3d/Unity/Unity_lic.ulf" ]; then + echo "Unity license file successfully generated or applied." + return 0 + else + echo "Failed to generate Unity license file. Please verify your inputs." return 1 fi } @@ -74,16 +90,14 @@ download_and_prepare_before_script() { } # Check if serial or encoded license was provided. -# If the latter, extract the serial from the license. if ! resolve_unity_license; then - printf '%s\n' "Failed to find the serial or parse it from the Unity license." - printf '%s\n' "Please try again or open an issue." + echo "Failed to activate Unity. Please check your inputs or open an issue." exit 1 fi # Define variables repo_url="https://gitlab.com/game-ci/unity3d-gitlab-ci-example" -ref="7fc1c95" # Will update to a tag once latest version is merged +ref="7fc1c95" # Will update to a tag once the latest version is merged file_path="ci/before_script.sh" before_script="$base_dir/before_script.sh" @@ -96,5 +110,7 @@ readonly UNITY_LICENSE="$unity_license" export UNITY_LICENSE # Run the test script. +echo "Running the before_script.sh from $repo_url at $ref." +# TODO: this will fail if user did not provide UNITY_SERIAL as env var. Also, relying on this external script is not ideal. # shellcheck source=/dev/null source "$before_script" diff --git a/src/scripts/linux/return-license.sh b/src/scripts/linux/return-license.sh index b0b526f..a1c13ed 100644 --- a/src/scripts/linux/return-license.sh +++ b/src/scripts/linux/return-license.sh @@ -11,5 +11,6 @@ unity-editor \ -returnlicense \ -username "$unity_username" \ -password "$unity_password" \ + -password "$unity_serial" \ -logfile /dev/stdout -set +x \ No newline at end of file +set +x diff --git a/src/scripts/macos/prepare-env.sh b/src/scripts/macos/prepare-env.sh index 244ef10..555e1f1 100644 --- a/src/scripts/macos/prepare-env.sh +++ b/src/scripts/macos/prepare-env.sh @@ -162,6 +162,6 @@ set -x -nographics \ -username "$unity_username" \ -password "$unity_password" \ - -serial "$resolved_unity_serial" \ + -serial "$unity_serial" \ -logfile /dev/stdout set +x diff --git a/src/scripts/macos/return-license.sh b/src/scripts/macos/return-license.sh index f91987f..f1d8385 100644 --- a/src/scripts/macos/return-license.sh +++ b/src/scripts/macos/return-license.sh @@ -11,5 +11,6 @@ set -x -returnlicense \ -username "$unity_username" \ -password "$unity_password" \ + -password "$unity_serial" \ -logfile /dev/stdout -set +x \ No newline at end of file +set +x From 7bb5a2f376d7157f2afb4c5d01bd3657b39f4d75 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 22:45:51 -0500 Subject: [PATCH 04/10] Update Unity serial handling and usage in macOS script --- src/commands/prepare-env.yml | 1 - src/scripts/macos/prepare-env.sh | 45 +++++++++++++++----------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/commands/prepare-env.yml b/src/commands/prepare-env.yml index 20dafa9..723ea37 100644 --- a/src/commands/prepare-env.yml +++ b/src/commands/prepare-env.yml @@ -51,7 +51,6 @@ steps: PARAM_UNITY_USERNAME_VAR_NAME: << parameters.unity-username-var-name >> PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >> PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >> - PARAM_UNITY_LICENSE_VAR_NAME: << parameters.unity-license-var-name >> PARAM_PROJECT_PATH: << parameters.project-path >> SCRIPT_PREPARE_ENV_LINUX: << include(scripts/linux/prepare-env.sh) >> SCRIPT_PREPARE_ENV_WINDOWS: << include(scripts/windows/prepare-env.sh) >> diff --git a/src/scripts/macos/prepare-env.sh b/src/scripts/macos/prepare-env.sh index 555e1f1..4e6db7d 100644 --- a/src/scripts/macos/prepare-env.sh +++ b/src/scripts/macos/prepare-env.sh @@ -79,33 +79,30 @@ check_and_install_unity_editor() { } resolve_unity_serial() { - if [ -n "$unity_username" ] && [ -n "$unity_password" ]; then - # Serial provided. - if [ -n "$unity_serial" ]; then - printf '%s\n' "Detected Unity serial." - readonly resolved_unity_serial="$unity_serial" - - # License provided. - elif [ -n "$unity_encoded_license" ]; then - printf '%s\n' "No serial detected. Extracting it from the encoded license." - - if ! extract_serial_from_license; then - printf '%s\n' "Failed to parse the serial from the Unity license." - printf '%s\n' "Please try again or open an issue." - printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation#personal-license" - return 1 + if [ -n "$unity_username" ] && [ -n "$unity_password" ] && [ -n "$unity_serial" ]; then + printf '%s\n' "Detected Unity serial." + resolved_unity_serial="$unity_serial" - else - readonly resolved_unity_serial="$decoded_unity_serial" - fi + # License provided. + elif [ -n "$unity_encoded_license" ]; then + printf '%s\n' "No serial detected. Extracting it from the encoded license." - # Nothing provided. - else - printf '%s\n' "No serial or encoded license found." - printf '%s\n' "Please run the script again with a serial or encoded license file." - printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation" + if ! extract_serial_from_license; then + printf '%s\n' "Failed to parse the serial from the Unity license." + printf '%s\n' "Please try again or open an issue." + printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation#personal-license" return 1 + + else + readonly resolved_unity_serial="$decoded_unity_serial" fi + + # Nothing provided. + else + printf '%s\n' "No serial or encoded license found." + printf '%s\n' "Please run the script again with a serial or encoded license file." + printf '%s\n' "See the docs for more details: https://game.ci/docs/circleci/activation" + return 1 fi return 0 @@ -162,6 +159,6 @@ set -x -nographics \ -username "$unity_username" \ -password "$unity_password" \ - -serial "$unity_serial" \ + -serial "$resolved_unity_serial" \ -logfile /dev/stdout set +x From b6295ea49cf24293166d27cf61deb014983d6ee4 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 22:47:15 -0500 Subject: [PATCH 05/10] Update serial flag in return-license script for Linux and macOS --- src/scripts/linux/return-license.sh | 2 +- src/scripts/macos/return-license.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/linux/return-license.sh b/src/scripts/linux/return-license.sh index a1c13ed..8742370 100644 --- a/src/scripts/linux/return-license.sh +++ b/src/scripts/linux/return-license.sh @@ -11,6 +11,6 @@ unity-editor \ -returnlicense \ -username "$unity_username" \ -password "$unity_password" \ - -password "$unity_serial" \ + -serial "$unity_serial" \ -logfile /dev/stdout set +x diff --git a/src/scripts/macos/return-license.sh b/src/scripts/macos/return-license.sh index f1d8385..446a864 100644 --- a/src/scripts/macos/return-license.sh +++ b/src/scripts/macos/return-license.sh @@ -11,6 +11,6 @@ set -x -returnlicense \ -username "$unity_username" \ -password "$unity_password" \ - -password "$unity_serial" \ + -serial "$unity_serial" \ -logfile /dev/stdout set +x From 05f93d569e98ac85bf167666de34bf3e687901df Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 22:50:37 -0500 Subject: [PATCH 06/10] Remove unused variable and add serial in return license script --- src/scripts/prepare-env.sh | 1 - src/scripts/return-license.sh | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/prepare-env.sh b/src/scripts/prepare-env.sh index bb099c6..cea11a9 100644 --- a/src/scripts/prepare-env.sh +++ b/src/scripts/prepare-env.sh @@ -14,7 +14,6 @@ detect-os readonly unity_username="${!PARAM_UNITY_USERNAME_VAR_NAME}" readonly unity_password="${!PARAM_UNITY_PASSWORD_VAR_NAME}" readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" -readonly unity_encoded_license="${!PARAM_UNITY_LICENSE_VAR_NAME}" if [ "$PLATFORM" = "linux" ]; then eval "$SCRIPT_PREPARE_ENV_LINUX"; elif [ "$PLATFORM" = "macos" ]; then eval "$SCRIPT_PREPARE_ENV_MACOS"; diff --git a/src/scripts/return-license.sh b/src/scripts/return-license.sh index d4ffc11..3bfea0d 100644 --- a/src/scripts/return-license.sh +++ b/src/scripts/return-license.sh @@ -12,8 +12,9 @@ detect-os # Expand environment name variable parameters. readonly unity_username="${!PARAM_UNITY_USERNAME_VAR_NAME}" readonly unity_password="${!PARAM_UNITY_PASSWORD_VAR_NAME}" +readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" if [ "$PLATFORM" = "linux" ]; then eval "$SCRIPT_RETURN_LICENSE_LINUX"; elif [ "$PLATFORM" = "macos" ]; then eval "$SCRIPT_RETURN_LICENSE_MACOS"; elif [ "$PLATFORM" = "windows" ]; then eval "$SCRIPT_RETURN_LICENSE_WINDOWS"; -fi \ No newline at end of file +fi From 77ea6a62cf58020fee5ea3086662200db02bc727 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Thu, 21 Nov 2024 23:00:18 -0500 Subject: [PATCH 07/10] Update Unity variable name to "UNITY_EMAIL" in all files --- .circleci/test-deploy.yml | 44 +++++++++---------- src/commands/prepare-env.yml | 6 +-- src/commands/return-license.yml | 6 +-- .../test_and_build_personal_license.yml | 12 ++--- .../test_and_build_pro_or_plus_license.yml | 16 +++---- src/jobs/build.yml | 8 ++-- src/jobs/test.yml | 8 ++-- src/scripts/linux/prepare-env.sh | 6 +-- src/scripts/linux/return-license.sh | 2 +- src/scripts/macos/prepare-env.sh | 4 +- src/scripts/macos/return-license.sh | 2 +- src/scripts/prepare-env.sh | 2 +- src/scripts/return-license.sh | 2 +- src/scripts/windows/prepare-env.sh | 6 +-- src/scripts/windows/return-license.sh | 4 +- 15 files changed, 64 insertions(+), 64 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 326deba..c604782 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -81,7 +81,7 @@ workflows: - unity/test: name: "test-linux" step-name: "Check if the tests run and results are uploaded" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -97,7 +97,7 @@ workflows: - unity/test: name: "test-linux-with-custom-parameters" step-name: "Check if test filter in custom parameter works" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -114,7 +114,7 @@ workflows: # - unity/test: # name: "test-windows" # step-name: "Check if the tests run and results are uploaded" - # unity-username-var-name: "UNITY_USERNAME" + # unity-email-var-name: "UNITY_EMAIL" # unity-password-var-name: "UNITY_PASSWORD" # unity-serial-var-name: "UNITY_SERIAL" # serial-password-var-name: "UNITY_SERIAL" @@ -131,7 +131,7 @@ workflows: # - unity/test: # name: "test-windows-with-custom-parameters" # step-name: "Check if test filter in custom parameter works" - # unity-username-var-name: "UNITY_USERNAME" + # unity-email-var-name: "UNITY_EMAIL" # unity-password-var-name: "UNITY_PASSWORD" # unity-serial-var-name: "UNITY_SERIAL" # executor: @@ -148,7 +148,7 @@ workflows: - unity/test: name: "test-osx" step-name: "Check if the tests run and results are uploaded" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -163,7 +163,7 @@ workflows: - unity/test: name: "test-osx-with-custom-parameters" step-name: "Check if test filter in custom parameter works" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -181,7 +181,7 @@ workflows: - unity/build: name: "build-linux64-il2cpp" step-name: "Build StandaloneLinux64" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -198,7 +198,7 @@ workflows: # - unity/build: # name: "build-Windows64-il2cpp" # step-name: "Build StandaloneWindows64 il2cpp" - # unity-username-var-name: "UNITY_USERNAME" + # unity-email-var-name: "UNITY_EMAIL" # unity-password-var-name: "UNITY_PASSWORD" # unity-serial-var-name: "UNITY_SERIAL" # executor: @@ -215,7 +215,7 @@ workflows: - unity/build: name: "build-osx-il2cpp" step-name: "Build macOS IL2CPP" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -233,7 +233,7 @@ workflows: - unity/build: name: "build-linux64-mono" step-name: "Build StandaloneLinux64" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -250,7 +250,7 @@ workflows: - unity/build: name: "build-Windows64-mono" step-name: "Build StandaloneWindows64" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -266,7 +266,7 @@ workflows: - unity/build: name: "build-osx-mono" step-name: "Build StandaloneOSX" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -284,7 +284,7 @@ workflows: - unity/build: name: "build-webgl" step-name: "Build WebGL" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -301,7 +301,7 @@ workflows: - unity/build: name: "build-android" step-name: "Build Android" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -317,7 +317,7 @@ workflows: - unity/build: name: "build-ios" step-name: "Build iOS" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -333,7 +333,7 @@ workflows: # - unity/build: # name: "build-tvOS" # step-name: "Build Apple's tvOS" - # unity-username-var-name: "UNITY_USERNAME" + # unity-email-var-name: "UNITY_EMAIL" # unity-password-var-name: "UNITY_PASSWORD" # unity-serial-var-name: "UNITY_SERIAL" # executor: @@ -352,7 +352,7 @@ workflows: - unity/build: name: "build-without-artifacts" step-name: "Build StandaloneLinux64 with no artifacts" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -369,7 +369,7 @@ workflows: # - unity/build: # name: "build-with-custom-method-windows" # step-name: "Build with custom method in Windows" - # unity-username-var-name: "UNITY_USERNAME" + # unity-email-var-name: "UNITY_EMAIL" # unity-password-var-name: "UNITY_PASSWORD" # unity-serial-var-name: "UNITY_SERIAL" # executor: @@ -387,7 +387,7 @@ workflows: - unity/build: name: "build-with-custom-method-osx" step-name: "Build with custom method in macOS" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -404,7 +404,7 @@ workflows: - unity/build: name: "build-with-custom-method-linux" step-name: "Build with custom method in Linux" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -423,7 +423,7 @@ workflows: - unity/build: name: "build-with-workspace" step-name: "Build StandaloneLinux64 with workspace" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: @@ -444,7 +444,7 @@ workflows: - unity/build: name: "compress-build-with-workspace" step-name: "Compress build StandaloneLinux64 with workspace" - unity-username-var-name: "UNITY_USERNAME" + unity-email-var-name: "UNITY_EMAIL" unity-password-var-name: "UNITY_PASSWORD" unity-serial-var-name: "UNITY_SERIAL" executor: diff --git a/src/commands/prepare-env.yml b/src/commands/prepare-env.yml index 723ea37..8a01c67 100644 --- a/src/commands/prepare-env.yml +++ b/src/commands/prepare-env.yml @@ -2,9 +2,9 @@ description: > This command prepares the environment for testing or building an Unity project. parameters: - unity-username-var-name: + unity-email-var-name: type: env_var_name - default: "UNITY_USERNAME" + default: "UNITY_EMAIL" description: | Enter the name of the environment variable containing your Unity username. unity-password-var-name: @@ -48,7 +48,7 @@ steps: name: Prepare the environment no_output_timeout: << parameters.no_output_timeout >> environment: - PARAM_UNITY_USERNAME_VAR_NAME: << parameters.unity-username-var-name >> + PARAM_UNITY_EMAIL_VAR_NAME: << parameters.unity-email-var-name >> PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >> PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >> PARAM_PROJECT_PATH: << parameters.project-path >> diff --git a/src/commands/return-license.yml b/src/commands/return-license.yml index e73f20a..2e2e992 100644 --- a/src/commands/return-license.yml +++ b/src/commands/return-license.yml @@ -2,9 +2,9 @@ description: > This command returns the license used to build or test the project. parameters: - unity-username-var-name: + unity-email-var-name: type: env_var_name - default: "UNITY_USERNAME" + default: "UNITY_EMAIL" description: | Enter the name of the environment variable containing your Unity username. unity-password-var-name: @@ -26,7 +26,7 @@ steps: - run: name: Return the Unity license environment: - PARAM_UNITY_USERNAME_VAR_NAME: << parameters.unity-username-var-name >> + PARAM_UNITY_EMAIL_VAR_NAME: << parameters.unity-email-var-name >> PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >> SCRIPT_RETURN_LICENSE_LINUX: << include(scripts/linux/return-license.sh) >> SCRIPT_RETURN_LICENSE_WINDOWS: << include(scripts/windows/return-license.sh) >> diff --git a/src/examples/test_and_build_personal_license.yml b/src/examples/test_and_build_personal_license.yml index 32a43be..7d2a74c 100755 --- a/src/examples/test_and_build_personal_license.yml +++ b/src/examples/test_and_build_personal_license.yml @@ -17,7 +17,7 @@ usage: - unity/test: name: 'test-linux' step-name: 'Check if the tests run and results are uploaded' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: @@ -31,7 +31,7 @@ usage: - unity/build: name: 'build-linux64-il2cpp' step-name: 'Build StandaloneLinux64' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: @@ -49,7 +49,7 @@ usage: - unity/test: name: 'test-windows' step-name: 'Check if the tests run and results are uploaded' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: @@ -63,7 +63,7 @@ usage: - unity/build: name: 'build-Windows64-il2cpp' step-name: 'Build StandaloneWindows64 il2cpp' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: @@ -81,7 +81,7 @@ usage: - unity/test: name: 'test-osx' step-name: 'Check if the tests run and results are uploaded' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: @@ -94,7 +94,7 @@ usage: - unity/build: name: 'build-osx-il2cpp' step-name: 'Build macOS IL2CPP' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: 'UNITY_SERIAL' executor: diff --git a/src/examples/test_and_build_pro_or_plus_license.yml b/src/examples/test_and_build_pro_or_plus_license.yml index 5c27cfb..19642d3 100755 --- a/src/examples/test_and_build_pro_or_plus_license.yml +++ b/src/examples/test_and_build_pro_or_plus_license.yml @@ -17,9 +17,9 @@ usage: - unity/test: name: 'test-linux' step-name: 'Check if the tests run and results are uploaded' - unity-serial-var-name: "UNITY_SERIAL" - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/ubuntu' target_platform: 'linux-il2cpp' @@ -31,9 +31,9 @@ usage: - unity/build: name: 'build-linux64-il2cpp' step-name: 'Build StandaloneLinux64' - unity-serial-var-name: "UNITY_SERIAL" - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' + unity-serial-var-name: "UNITY_SERIAL" executor: name: 'unity/ubuntu' target_platform: 'linux-il2cpp' @@ -49,7 +49,7 @@ usage: - unity/test: name: 'test-windows' step-name: 'Check if the tests run and results are uploaded' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: "UNITY_SERIAL" executor: @@ -63,7 +63,7 @@ usage: - unity/build: name: 'build-Windows64-il2cpp' step-name: 'Build StandaloneWindows64 il2cpp' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: "UNITY_SERIAL" executor: @@ -81,7 +81,7 @@ usage: - unity/test: name: 'test-osx' step-name: 'Check if the tests run and results are uploaded' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: "UNITY_SERIAL" executor: @@ -94,7 +94,7 @@ usage: - unity/build: name: 'build-osx-il2cpp' step-name: 'Build macOS IL2CPP' - unity-username-var-name: 'UNITY_USERNAME' + unity-email-var-name: 'UNITY_EMAIL' unity-password-var-name: 'UNITY_PASSWORD' unity-serial-var-name: "UNITY_SERIAL" executor: diff --git a/src/jobs/build.yml b/src/jobs/build.yml index 6a336e2..ab3b0e2 100755 --- a/src/jobs/build.yml +++ b/src/jobs/build.yml @@ -11,9 +11,9 @@ parameters: type: executor description: | Pick an Executor to run the build job with. - unity-username-var-name: + unity-email-var-name: type: env_var_name - default: "UNITY_USERNAME" + default: "UNITY_EMAIL" description: | Enter the name of the environment variable containing your Unity username. unity-password-var-name: @@ -106,7 +106,7 @@ steps: git submodule update --init condition: << parameters.fetch-submodules >> - prepare-env: - unity-username-var-name: << parameters.unity-username-var-name >> + unity-email-var-name: << parameters.unity-email-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> unity-serial-var-name: << parameters.unity-serial-var-name >> project-path: <> @@ -126,5 +126,5 @@ steps: condition: <> steps: - return-license: - unity-username-var-name: << parameters.unity-username-var-name >> + unity-email-var-name: << parameters.unity-email-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> diff --git a/src/jobs/test.yml b/src/jobs/test.yml index d5954ff..f44c262 100644 --- a/src/jobs/test.yml +++ b/src/jobs/test.yml @@ -11,9 +11,9 @@ parameters: type: executor description: | Pick an Executor to run the build job with. - unity-username-var-name: + unity-email-var-name: type: env_var_name - default: "UNITY_USERNAME" + default: "UNITY_EMAIL" description: | Enter the name of the environment variable containing your Unity username. unity-password-var-name: @@ -67,7 +67,7 @@ executor: << parameters.executor >> steps: - checkout - prepare-env: - unity-username-var-name: << parameters.unity-username-var-name >> + unity-email-var-name: << parameters.unity-email-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> unity-serial-var-name: << parameters.unity-serial-var-name >> project-path: <> @@ -82,5 +82,5 @@ steps: condition: <> steps: - return-license: - unity-username-var-name: << parameters.unity-username-var-name >> + unity-email-var-name: << parameters.unity-email-var-name >> unity-password-var-name: << parameters.unity-password-var-name >> diff --git a/src/scripts/linux/prepare-env.sh b/src/scripts/linux/prepare-env.sh index 147708e..3de702e 100644 --- a/src/scripts/linux/prepare-env.sh +++ b/src/scripts/linux/prepare-env.sh @@ -3,7 +3,7 @@ # shellcheck disable=SC2154 resolve_unity_license() { - if [ -n "$unity_username" ] && [ -n "$unity_password" ]; then + if [ -n "$unity_email" ] && [ -n "$unity_password" ]; then if [ -n "$unity_serial" ]; then # Combination: username + email + serial echo "Activating Unity with username, password, and serial." @@ -12,7 +12,7 @@ resolve_unity_license() { -batchmode \ -nographics \ -quit \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ -serial "$unity_serial" @@ -35,7 +35,7 @@ resolve_unity_license() { -batchmode \ -nographics \ -quit \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ -serial "$unity_serial" diff --git a/src/scripts/linux/return-license.sh b/src/scripts/linux/return-license.sh index 8742370..b93073c 100644 --- a/src/scripts/linux/return-license.sh +++ b/src/scripts/linux/return-license.sh @@ -9,7 +9,7 @@ unity-editor \ -batchmode \ -nographics \ -returnlicense \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ -serial "$unity_serial" \ -logfile /dev/stdout diff --git a/src/scripts/macos/prepare-env.sh b/src/scripts/macos/prepare-env.sh index 4e6db7d..48284ee 100644 --- a/src/scripts/macos/prepare-env.sh +++ b/src/scripts/macos/prepare-env.sh @@ -79,7 +79,7 @@ check_and_install_unity_editor() { } resolve_unity_serial() { - if [ -n "$unity_username" ] && [ -n "$unity_password" ] && [ -n "$unity_serial" ]; then + if [ -n "$unity_email" ] && [ -n "$unity_password" ] && [ -n "$unity_serial" ]; then printf '%s\n' "Detected Unity serial." resolved_unity_serial="$unity_serial" @@ -157,7 +157,7 @@ set -x -batchmode \ -quit \ -nographics \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ -serial "$resolved_unity_serial" \ -logfile /dev/stdout diff --git a/src/scripts/macos/return-license.sh b/src/scripts/macos/return-license.sh index 446a864..1ab41e0 100644 --- a/src/scripts/macos/return-license.sh +++ b/src/scripts/macos/return-license.sh @@ -9,7 +9,7 @@ set -x -batchmode \ -nographics \ -returnlicense \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ -serial "$unity_serial" \ -logfile /dev/stdout diff --git a/src/scripts/prepare-env.sh b/src/scripts/prepare-env.sh index cea11a9..b2e4316 100644 --- a/src/scripts/prepare-env.sh +++ b/src/scripts/prepare-env.sh @@ -11,7 +11,7 @@ eval "$SCRIPT_UTILS" detect-os # Expand environment name variable parameters. -readonly unity_username="${!PARAM_UNITY_USERNAME_VAR_NAME}" +readonly unity_email="${!PARAM_UNITY_EMAIL_VAR_NAME}" readonly unity_password="${!PARAM_UNITY_PASSWORD_VAR_NAME}" readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" diff --git a/src/scripts/return-license.sh b/src/scripts/return-license.sh index 3bfea0d..3d7001b 100644 --- a/src/scripts/return-license.sh +++ b/src/scripts/return-license.sh @@ -10,7 +10,7 @@ eval "$SCRIPT_UTILS" detect-os # Expand environment name variable parameters. -readonly unity_username="${!PARAM_UNITY_USERNAME_VAR_NAME}" +readonly unity_email="${!PARAM_UNITY_EMAIL_VAR_NAME}" readonly unity_password="${!PARAM_UNITY_PASSWORD_VAR_NAME}" readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" diff --git a/src/scripts/windows/prepare-env.sh b/src/scripts/windows/prepare-env.sh index f38f5d3..4efe094 100644 --- a/src/scripts/windows/prepare-env.sh +++ b/src/scripts/windows/prepare-env.sh @@ -19,7 +19,7 @@ trap trap_exit EXIT resolve_unity_serial() { local exit_code=0 - if [ -n "$unity_username" ] && [ -n "$unity_password" ]; then + if [ -n "$unity_email" ] && [ -n "$unity_password" ]; then # Serial provided. if [ -n "$unity_serial" ]; then printf '%s\n' "Detected Unity serial." @@ -104,7 +104,7 @@ set -x docker run -dit \ --name "$container_name" \ --env PROJECT_PATH="C:/unity_project" \ - --env UNITY_USERNAME="$unity_username" \ + --env UNITY_EMAIL="$unity_email" \ --env UNITY_PASSWORD="$unity_password" \ --env UNITY_SERIAL="$resolved_unity_serial" \ --volume "$unity_project_full_path":C:/unity_project \ @@ -124,4 +124,4 @@ docker exec "$container_name" powershell 'reg import C:\regkeys\winsdk.reg' docker exec "$container_name" powershell 'regsvr32 /s C:\ProgramData\Microsoft\VisualStudio\Setup\x64\Microsoft.VisualStudio.Setup.Configuration.Native.dll' # Activate Unity -docker exec "$container_name" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -username $Env:UNITY_USERNAME -password $Env:UNITY_PASSWORD -serial $Env:UNITY_SERIAL -logfile | Out-Host' +docker exec "$container_name" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -quit -nographics -username $Env:UNITY_EMAIL -password $Env:UNITY_PASSWORD -serial $Env:UNITY_SERIAL -logfile | Out-Host' diff --git a/src/scripts/windows/return-license.sh b/src/scripts/windows/return-license.sh index 345bed7..1733b3f 100644 --- a/src/scripts/windows/return-license.sh +++ b/src/scripts/windows/return-license.sh @@ -18,8 +18,8 @@ trap trap_exit EXIT set -x # Return license -docker exec "$CONTAINER_NAME" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -returnlicense -batchmode -quit -nographics -username $Env:UNITY_USERNAME -password $Env:UNITY_PASSWORD -logfile | Out-Host' +docker exec "$CONTAINER_NAME" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -returnlicense -batchmode -quit -nographics -username $Env:UNITY_EMAIL -password $Env:UNITY_PASSWORD -logfile | Out-Host' set +x # Remove the container. -docker rm -f "$CONTAINER_NAME" \ No newline at end of file +docker rm -f "$CONTAINER_NAME" From 9a16695de022d41e753cd9663feb07398674c5b4 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Mon, 25 Nov 2024 09:22:29 -0500 Subject: [PATCH 08/10] Add unity serial var name parameter in return-license.yml --- src/commands/return-license.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/return-license.yml b/src/commands/return-license.yml index 2e2e992..17d4622 100644 --- a/src/commands/return-license.yml +++ b/src/commands/return-license.yml @@ -28,6 +28,7 @@ steps: environment: PARAM_UNITY_EMAIL_VAR_NAME: << parameters.unity-email-var-name >> PARAM_UNITY_PASSWORD_VAR_NAME: << parameters.unity-password-var-name >> + PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >> SCRIPT_RETURN_LICENSE_LINUX: << include(scripts/linux/return-license.sh) >> SCRIPT_RETURN_LICENSE_WINDOWS: << include(scripts/windows/return-license.sh) >> SCRIPT_RETURN_LICENSE_MACOS: << include(scripts/macos/return-license.sh) >> From 526072f5834c129eec6ea1ff227988b757027554 Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Mon, 25 Nov 2024 20:26:58 -0500 Subject: [PATCH 09/10] Update src/jobs/test.yml with better instructions Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/jobs/test.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/jobs/test.yml b/src/jobs/test.yml index f44c262..1cefe94 100644 --- a/src/jobs/test.yml +++ b/src/jobs/test.yml @@ -26,10 +26,19 @@ parameters: default: "UNITY_SERIAL" description: | Enter the name of the environment variable containing your Unity serial number. - Required even for personal license. - TODO: Improve documentation on how to extract from personal license, it's something like this: - cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode - For future versions, we could simply request the user to provide the ulf file and we could do the extraction. + Required even for personal license. To extract the serial from your Unity personal license file: + + 1. Locate your Unity license file (Unity_lic.ulf) + 2. Run the following command to extract the serial: + ``` + cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode + ``` + 3. Store the extracted serial securely in your CI environment variables + + Note: Keep your Unity serial number confidential as it's tied to your Unity account. + + Future Enhancement: We plan to simplify this process by directly accepting the .ulf file + and handling the extraction automatically within the orb. project-path: type: string default: "." From e0a23edf2de2bd51b5e1649655228bd9a2b7c80f Mon Sep 17 00:00:00 2001 From: Gabriel Le Breton Date: Mon, 25 Nov 2024 20:28:11 -0500 Subject: [PATCH 10/10] Revert "Update src/jobs/test.yml with better instructions" This reverts commit 526072f5834c129eec6ea1ff227988b757027554. --- src/jobs/test.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/jobs/test.yml b/src/jobs/test.yml index 1cefe94..f44c262 100644 --- a/src/jobs/test.yml +++ b/src/jobs/test.yml @@ -26,19 +26,10 @@ parameters: default: "UNITY_SERIAL" description: | Enter the name of the environment variable containing your Unity serial number. - Required even for personal license. To extract the serial from your Unity personal license file: - - 1. Locate your Unity license file (Unity_lic.ulf) - 2. Run the following command to extract the serial: - ``` - cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode - ``` - 3. Store the extracted serial securely in your CI environment variables - - Note: Keep your Unity serial number confidential as it's tied to your Unity account. - - Future Enhancement: We plan to simplify this process by directly accepting the .ulf file - and handling the extraction automatically within the orb. + Required even for personal license. + TODO: Improve documentation on how to extract from personal license, it's something like this: + cat Unity_lic.ulf | grep DeveloperData | sed -E 's/.*Value="([^"]+)".*/\1/' | base64 --decode + For future versions, we could simply request the user to provide the ulf file and we could do the extraction. project-path: type: string default: "."