Skip to content

Commit ab64768

Browse files
Enable unity licensing server for macOS (#735)
* Remove arguments for license activation from build step * Support Unity license server on macOS platform * Prepare configuration file to appropriate path * Use extended regular expression since mac uses BSD grep * Store the exit code from license activation command --------- Co-authored-by: Webber Takken <[email protected]>
1 parent 00fa0d3 commit ab64768

File tree

4 files changed

+95
-31
lines changed

4 files changed

+95
-31
lines changed

dist/platforms/mac/steps/activate.sh

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,69 @@
44
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
55
pushd "$ACTIVATE_LICENSE_PATH"
66

7-
echo "Requesting activation"
8-
9-
# Activate license
10-
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
11-
-logFile - \
12-
-batchmode \
13-
-nographics \
14-
-quit \
15-
-serial "$UNITY_SERIAL" \
16-
-username "$UNITY_EMAIL" \
17-
-password "$UNITY_PASSWORD" \
18-
-projectPath "$ACTIVATE_LICENSE_PATH"
19-
20-
# Store the exit code from the verify command
21-
UNITY_EXIT_CODE=$?
7+
if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
8+
#
9+
# SERIAL LICENSE MODE
10+
#
11+
# This will activate unity, using the serial activation process.
12+
#
13+
14+
echo "Requesting activation"
15+
16+
# Activate license
17+
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
18+
-logFile - \
19+
-batchmode \
20+
-nographics \
21+
-quit \
22+
-serial "$UNITY_SERIAL" \
23+
-username "$UNITY_EMAIL" \
24+
-password "$UNITY_PASSWORD" \
25+
-projectPath "$ACTIVATE_LICENSE_PATH"
26+
27+
# Store the exit code from the verify command
28+
UNITY_EXIT_CODE=$?
29+
30+
elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then
31+
#
32+
# Custom Unity License Server
33+
#
34+
echo "Adding licensing server config"
35+
mkdir -p "$UNITY_LICENSE_PATH/config/"
36+
cp "$ACTION_FOLDER/unity-config/services-config.json" "$UNITY_LICENSE_PATH/config/services-config.json"
37+
38+
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \
39+
--acquire-floating > license.txt
40+
41+
# Store the exit code from the verify command
42+
UNITY_EXIT_CODE=$?
43+
44+
if [ $UNITY_EXIT_CODE -eq 0 ]; then
45+
PARSEDFILE=$(grep -oE '\"[^"]*\"' < license.txt | tr -d '"')
46+
export FLOATING_LICENSE
47+
FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
48+
FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")
49+
50+
echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT"
51+
fi
52+
else
53+
#
54+
# NO LICENSE ACTIVATION STRATEGY MATCHED
55+
#
56+
# This will exit since no activation strategies could be matched.
57+
#
58+
echo "License activation strategy could not be determined."
59+
echo ""
60+
echo "Visit https://game.ci/docs/github/activation for more"
61+
echo "details on how to set up one of the possible activation strategies."
62+
63+
echo "::error ::No valid license activation strategy could be determined. Make sure to provide UNITY_EMAIL, UNITY_PASSWORD, and either a UNITY_SERIAL \
64+
or UNITY_LICENSE. Otherwise please use UNITY_LICENSING_SERVER. See more info at https://game.ci/docs/github/activation"
65+
66+
# Immediately exit as no UNITY_EXIT_CODE can be derived.
67+
exit 1;
68+
69+
fi
2270

2371
#
2472
# Display information about the result

dist/platforms/mac/steps/build.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ echo ""
149149
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
150150
-batchmode \
151151
$( [ "${ENABLE_GPU}" == "true" ] || echo "-nographics" ) \
152-
-username "$UNITY_EMAIL" \
153-
-password "$UNITY_PASSWORD" \
154152
-customBuildName "$BUILD_NAME" \
155153
-projectPath "$UNITY_PROJECT_PATH" \
156154
$( [ -z "$BUILD_PROFILE" ] && echo "-buildTarget $BUILD_TARGET") \

dist/platforms/mac/steps/return_license.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,29 @@
44
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
55
pushd "$ACTIVATE_LICENSE_PATH"
66

7-
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
8-
-logFile - \
9-
-batchmode \
10-
-nographics \
11-
-quit \
12-
-username "$UNITY_EMAIL" \
13-
-password "$UNITY_PASSWORD" \
14-
-returnlicense \
15-
-projectPath "$ACTIVATE_LICENSE_PATH"
7+
if [[ -n "$UNITY_LICENSING_SERVER" ]]; then
8+
#
9+
# Return any floating license used.
10+
#
11+
echo "Returning floating license: \"$FLOATING_LICENSE\""
12+
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/MacOS/Unity.Licensing.Client \
13+
--return-floating "$FLOATING_LICENSE"
14+
elif [[ -n "$UNITY_SERIAL" ]]; then
15+
#
16+
# SERIAL LICENSE MODE
17+
#
18+
# This will return the license that is currently in use.
19+
#
20+
/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
21+
-logFile - \
22+
-batchmode \
23+
-nographics \
24+
-quit \
25+
-username "$UNITY_EMAIL" \
26+
-password "$UNITY_PASSWORD" \
27+
-returnlicense \
28+
-projectPath "$ACTIVATE_LICENSE_PATH"
29+
fi
1630

1731
# Return to previous working directory
1832
popd

dist/platforms/ubuntu/steps/activate.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then
6868
echo "Adding licensing server config"
6969

7070
/opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable?
71-
PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"')
72-
export FLOATING_LICENSE
73-
FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
74-
FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")
7571

76-
echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT"
7772
# Store the exit code from the verify command
7873
UNITY_EXIT_CODE=$?
74+
75+
if [ $UNITY_EXIT_CODE -eq 0 ]; then
76+
PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"')
77+
export FLOATING_LICENSE
78+
FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
79+
FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")
80+
81+
echo "Acquired floating license: \"$FLOATING_LICENSE\" with timeout $FLOATING_LICENSE_TIMEOUT"
82+
fi
7983
else
8084
#
8185
# NO LICENSE ACTIVATION STRATEGY MATCHED

0 commit comments

Comments
 (0)