diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index 48ee65a..c604782 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-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" @@ -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-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" @@ -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-email-var-name: "UNITY_EMAIL" # 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-email-var-name: "UNITY_EMAIL" # 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-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" @@ -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-email-var-name: "UNITY_EMAIL" # 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" # 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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" # 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-email-var-name: "UNITY_EMAIL" 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-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" @@ -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-email-var-name: "UNITY_EMAIL" 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-email-var-name: "UNITY_EMAIL" 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..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: @@ -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" @@ -54,10 +48,9 @@ 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_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/commands/return-license.yml b/src/commands/return-license.yml index d6c2580..17d4622 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: @@ -12,13 +12,23 @@ 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: 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 >> + 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) >> diff --git a/src/examples/test_and_build_personal_license.yml b/src/examples/test_and_build_personal_license.yml index 8df4415..7d2a74c 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-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-license-var-name: 'UNITY_ENCODED_LICENSE' - 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,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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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..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,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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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-email-var-name: 'UNITY_EMAIL' 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..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: @@ -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: "." @@ -109,10 +106,9 @@ 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 >> - unity-license-var-name: << parameters.unity-license-var-name >> project-path: <> no_output_timeout: << parameters.no_output_timeout>> - build: @@ -130,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/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..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: @@ -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: "." @@ -70,10 +67,9 @@ 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 >> - unity-license-var-name: << parameters.unity-license-var-name >> project-path: <> no_output_timeout: << parameters.no_output_timeout>> - test: @@ -86,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 c90e48e..3fbb4aa 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_email" ] && [ -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_email" \ + -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_email" \ + -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 } @@ -89,10 +105,8 @@ 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 @@ -111,5 +125,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..b93073c 100644 --- a/src/scripts/linux/return-license.sh +++ b/src/scripts/linux/return-license.sh @@ -9,7 +9,8 @@ unity-editor \ -batchmode \ -nographics \ -returnlicense \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ + -serial "$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..48284ee 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_email" ] && [ -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 @@ -160,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 f91987f..1ab41e0 100644 --- a/src/scripts/macos/return-license.sh +++ b/src/scripts/macos/return-license.sh @@ -9,7 +9,8 @@ set -x -batchmode \ -nographics \ -returnlicense \ - -username "$unity_username" \ + -username "$unity_email" \ -password "$unity_password" \ + -serial "$unity_serial" \ -logfile /dev/stdout -set +x \ No newline at end of file +set +x diff --git a/src/scripts/prepare-env.sh b/src/scripts/prepare-env.sh index bb099c6..b2e4316 100644 --- a/src/scripts/prepare-env.sh +++ b/src/scripts/prepare-env.sh @@ -11,10 +11,9 @@ 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}" -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..3d7001b 100644 --- a/src/scripts/return-license.sh +++ b/src/scripts/return-license.sh @@ -10,10 +10,11 @@ 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}" 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 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"