Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor orb to support proper activation of unity using serial #83

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 45 additions & 51 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 3 additions & 10 deletions src/commands/prepare-env.yml
Original file line number Diff line number Diff line change
@@ -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) >>
16 changes: 13 additions & 3 deletions src/commands/return-license.yml
Original file line number Diff line number Diff line change
@@ -2,23 +2,33 @@ 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:
type: env_var_name
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.
Comment on lines +15 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Parameter unity-serial-var-name is defined but not properly integrated

The parameter is defined in the YAML but not passed to the environment variables in the steps section. Additionally, the shell scripts are using a hardcoded unity_serial variable instead of expanding the environment variable name parameter. This needs to be fixed:

  • In src/commands/return-license.yml: Add PARAM_UNITY_SERIAL_VAR_NAME: << parameters.unity-serial-var-name >> to the environment variables
  • In src/scripts/return-license.sh: Add readonly unity_serial="${!PARAM_UNITY_SERIAL_VAR_NAME}" along with other variable expansions
  • In platform-specific scripts (linux/return-license.sh, macos/return-license.sh): Update to use the expanded $unity_serial variable consistently
  • In windows/return-license.sh: Add -serial $Env:UNITY_SERIAL to the Unity command parameters
🔗 Analysis chain

Verify integration of unity-serial-var-name parameter

The new parameter is defined but not explicitly passed to the environment variables in the steps section. Let's verify its usage in the shell scripts.

Also applies to: 24-35


Let me try a different approach to locate the relevant files first.


Now let's check the actual usage of the parameter in the relevant shell scripts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if unity-serial-var-name is properly used in shell scripts

echo "Checking shell scripts for UNITY_SERIAL usage..."

# Check all shell scripts referenced in the YAML
for script in "scripts/linux/return-license.sh" "scripts/windows/return-license.sh" "scripts/macos/return-license.sh" "scripts/return-license.sh" "scripts/utils.sh"; do
  echo "\nChecking $script:"
  if [ -f "$script" ]; then
    # Look for UNITY_SERIAL or unity_serial usage
    rg -i "unity.?serial" "$script" || echo "No direct references found"
    
    # Look for parameter usage
    rg "PARAM_UNITY_SERIAL_VAR_NAME" "$script" || echo "No parameter references found"
  else
    echo "Script not found: $script"
  fi
done

Length of output: 2101


Script:

#!/bin/bash
# Find all shell scripts in the repository
echo "Finding all shell scripts in the repository..."
fd -e sh

# Find all YAML files that might reference the parameter
echo -e "\nFinding YAML files that mention unity-serial..."
rg -l -i "unity.?serial" -g "*.yml" -g "*.yaml"

Length of output: 1010


Script:

#!/bin/bash
# Check the content of return-license scripts
echo "Checking src/scripts/return-license.sh..."
cat src/scripts/return-license.sh

echo -e "\nChecking src/scripts/linux/return-license.sh..."
cat src/scripts/linux/return-license.sh

echo -e "\nChecking src/scripts/macos/return-license.sh..."
cat src/scripts/macos/return-license.sh

echo -e "\nChecking src/scripts/windows/return-license.sh..."
cat src/scripts/windows/return-license.sh

# Also check the YAML file to see how the parameter is passed
echo -e "\nChecking how the parameter is used in return-license.yml..."
cat src/commands/return-license.yml

Length of output: 4212


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) >>
24 changes: 12 additions & 12 deletions src/examples/test_and_build_personal_license.yml
Original file line number Diff line number Diff line change
@@ -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"
24 changes: 12 additions & 12 deletions src/examples/test_and_build_pro_or_plus_license.yml
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 8 additions & 12 deletions src/jobs/build.yml
Original file line number Diff line number Diff line change
@@ -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: <<parameters.project-path>>
no_output_timeout: << parameters.no_output_timeout>>
- build:
@@ -130,5 +126,5 @@ steps:
condition: <<parameters.return-license>>
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 >>
23 changes: 0 additions & 23 deletions src/jobs/create-activation-file.yml

This file was deleted.

20 changes: 8 additions & 12 deletions src/jobs/test.yml
Original file line number Diff line number Diff line change
@@ -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: <<parameters.project-path>>
no_output_timeout: << parameters.no_output_timeout>>
- test:
@@ -86,5 +82,5 @@ steps:
condition: <<parameters.return-license>>
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 >>
102 changes: 59 additions & 43 deletions src/scripts/linux/prepare-env.sh
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 3 additions & 2 deletions src/scripts/linux/return-license.sh
Original file line number Diff line number Diff line change
@@ -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
set +x
45 changes: 21 additions & 24 deletions src/scripts/macos/prepare-env.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions src/scripts/macos/return-license.sh
Original file line number Diff line number Diff line change
@@ -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
set +x
3 changes: 1 addition & 2 deletions src/scripts/prepare-env.sh
Original file line number Diff line number Diff line change
@@ -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";
5 changes: 3 additions & 2 deletions src/scripts/return-license.sh
Original file line number Diff line number Diff line change
@@ -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
fi
6 changes: 3 additions & 3 deletions src/scripts/windows/prepare-env.sh
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 2 additions & 2 deletions src/scripts/windows/return-license.sh
Original file line number Diff line number Diff line change
@@ -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"
docker rm -f "$CONTAINER_NAME"