From 24f86eb7e16efb8ee974f772cf016b96795f808b Mon Sep 17 00:00:00 2001 From: Pyeongseok Oh Date: Wed, 10 Sep 2025 16:27:24 +0900 Subject: [PATCH 1/5] Remove arguments for license activation from build step --- dist/platforms/mac/steps/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/dist/platforms/mac/steps/build.sh b/dist/platforms/mac/steps/build.sh index 8149c49a..7d2080f7 100755 --- a/dist/platforms/mac/steps/build.sh +++ b/dist/platforms/mac/steps/build.sh @@ -149,8 +149,6 @@ echo "" $( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \ -batchmode \ $( [ "${ENABLE_GPU}" == "true" ] || echo "-nographics" ) \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ -customBuildName "$BUILD_NAME" \ -projectPath "$UNITY_PROJECT_PATH" \ -buildTarget "$BUILD_TARGET" \ From e5a2f8262e9926fd7228a053e3be2cf941f3a661 Mon Sep 17 00:00:00 2001 From: Pyeongseok Oh Date: Wed, 10 Sep 2025 16:59:25 +0900 Subject: [PATCH 2/5] Support Unity license server on macOS platform --- dist/platforms/mac/steps/activate.sh | 68 +++++++++++++++++----- dist/platforms/mac/steps/return_license.sh | 32 +++++++--- 2 files changed, 78 insertions(+), 22 deletions(-) diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index 3f749f04..752018e2 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -4,21 +4,63 @@ echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." pushd "$ACTIVATE_LICENSE_PATH" -echo "Requesting activation" +if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then + # + # SERIAL LICENSE MODE + # + # This will activate unity, using the serial activation process. + # -# Activate license -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -serial "$UNITY_SERIAL" \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -projectPath "$ACTIVATE_LICENSE_PATH" + echo "Requesting activation" -# Store the exit code from the verify command -UNITY_EXIT_CODE=$? + # Activate license + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ + -logFile - \ + -batchmode \ + -nographics \ + -quit \ + -serial "$UNITY_SERIAL" \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -projectPath "$ACTIVATE_LICENSE_PATH" + + # Store the exit code from the verify command + UNITY_EXIT_CODE=$? + +elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then + # + # Custom Unity License Server + # + echo "Adding licensing server config" + + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \ + --acquire-floating > license.txt + PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"') + export FLOATING_LICENSE + FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") + FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") + + echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT" + # Store the exit code from the verify command + UNITY_EXIT_CODE=$? +else + # + # NO LICENSE ACTIVATION STRATEGY MATCHED + # + # This will exit since no activation strategies could be matched. + # + echo "License activation strategy could not be determined." + echo "" + echo "Visit https://game.ci/docs/github/activation for more" + echo "details on how to set up one of the possible activation strategies." + + echo "::error ::No valid license activation strategy could be determined. Make sure to provide UNITY_EMAIL, UNITY_PASSWORD, and either a UNITY_SERIAL \ +or UNITY_LICENSE. Otherwise please use UNITY_LICENSING_SERVER. See more info at https://game.ci/docs/github/activation" + + # Immediately exit as no UNITY_EXIT_CODE can be derived. + exit 1; + +fi # # Display information about the result diff --git a/dist/platforms/mac/steps/return_license.sh b/dist/platforms/mac/steps/return_license.sh index 1749f9e7..c7748fcc 100755 --- a/dist/platforms/mac/steps/return_license.sh +++ b/dist/platforms/mac/steps/return_license.sh @@ -4,15 +4,29 @@ echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." pushd "$ACTIVATE_LICENSE_PATH" -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -returnlicense \ - -projectPath "$ACTIVATE_LICENSE_PATH" +if [[ -n "$UNITY_LICENSING_SERVER" ]]; then + # + # Return any floating license used. + # + echo "Returning floating license: \"$FLOATING_LICENSE\"" + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \ + --return-floating "$FLOATING_LICENSE" +elif [[ -n "$UNITY_SERIAL" ]]; then + # + # SERIAL LICENSE MODE + # + # This will return the license that is currently in use. + # + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ + -logFile - \ + -batchmode \ + -nographics \ + -quit \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -returnlicense \ + -projectPath "$ACTIVATE_LICENSE_PATH" +fi # Return to previous working directory popd From 212147f7b185be43b8b39c9fe56699b8cc09cb86 Mon Sep 17 00:00:00 2001 From: Pyeongseok Oh Date: Wed, 10 Sep 2025 18:20:18 +0900 Subject: [PATCH 3/5] Prepare configuration file to appropriate path --- dist/platforms/mac/steps/activate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index 752018e2..f7ea1fc7 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -32,6 +32,8 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then # Custom Unity License Server # echo "Adding licensing server config" + mkdir -p "$UNITY_LICENSE_PATH/config/" + cp "$ACTION_FOLDER/unity-config/services-config.json" "$UNITY_LICENSE_PATH/config/services-config.json" /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \ --acquire-floating > license.txt From 7e34468125c4856bd8f7e08050cdd5b1dd762d58 Mon Sep 17 00:00:00 2001 From: Pyeongseok Oh Date: Thu, 11 Sep 2025 12:55:53 +0900 Subject: [PATCH 4/5] Use extended regular expression since mac uses BSD grep --- dist/platforms/mac/steps/activate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index f7ea1fc7..c9569a80 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -37,7 +37,7 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \ --acquire-floating > license.txt - PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"') + PARSEDFILE=$(grep -oE '\"[^"]*\"' < license.txt | tr -d '"') export FLOATING_LICENSE FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") From d81fb8a1f53b66d299c10741534feff00e3fec2f Mon Sep 17 00:00:00 2001 From: Pyeongseok Oh Date: Thu, 11 Sep 2025 13:10:01 +0900 Subject: [PATCH 5/5] Store the exit code from license activation command --- dist/platforms/mac/steps/activate.sh | 14 +++++++++----- dist/platforms/ubuntu/steps/activate.sh | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index c9569a80..92f4e9e8 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -37,14 +37,18 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \ --acquire-floating > license.txt - PARSEDFILE=$(grep -oE '\"[^"]*\"' < license.txt | tr -d '"') - export FLOATING_LICENSE - FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") - FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") - echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT" # Store the exit code from the verify command UNITY_EXIT_CODE=$? + + if [ $UNITY_EXIT_CODE -eq 0 ]; then + PARSEDFILE=$(grep -oE '\"[^"]*\"' < license.txt | tr -d '"') + export FLOATING_LICENSE + FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") + FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") + + echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT" + fi else # # NO LICENSE ACTIVATION STRATEGY MATCHED diff --git a/dist/platforms/ubuntu/steps/activate.sh b/dist/platforms/ubuntu/steps/activate.sh index 9566d92d..70049cce 100755 --- a/dist/platforms/ubuntu/steps/activate.sh +++ b/dist/platforms/ubuntu/steps/activate.sh @@ -68,14 +68,18 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then echo "Adding licensing server config" /opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable? - PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"') - export FLOATING_LICENSE - FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") - FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") - echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT" # Store the exit code from the verify command UNITY_EXIT_CODE=$? + + if [ $UNITY_EXIT_CODE -eq 0 ]; then + PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"') + export FLOATING_LICENSE + FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE") + FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE") + + echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT" + fi else # # NO LICENSE ACTIVATION STRATEGY MATCHED