Skip to content

Commit f2250e9

Browse files
authored
Enable unity licensing server for Windows (#638)
* Enable unity licensing server for windows * Clarify validating logic with explicit variables
1 parent dd42746 commit f2250e9

File tree

6 files changed

+51
-8
lines changed

6 files changed

+51
-8
lines changed

dist/index.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/windows/activate.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ if ( ($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($
5050
Start-Sleep -Seconds 3
5151
}
5252
}
53+
elseif( ($null -ne ${env:UNITY_LICENSING_SERVER}))
54+
{
55+
#
56+
# Custom Unity License Server
57+
#
58+
59+
Write-Output "Adding licensing server config"
60+
61+
$ACTIVATION_OUTPUT = Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" `
62+
-ArgumentList "--acquire-floating" `
63+
-NoNewWindow `
64+
-PassThru `
65+
-Wait `
66+
-RedirectStandardOutput "license.txt"
67+
68+
$PARSEDFILE = (Get-Content "license.txt" | Select-String -AllMatches -Pattern '\".*?\"' | ForEach-Object { $_.Matches.Value }) -replace '"'
69+
70+
$env:FLOATING_LICENSE = $PARSEDFILE[1]
71+
$FLOATING_LICENSE_TIMEOUT = $PARSEDFILE[3]
72+
73+
Write-Output "Acquired floating license: ""$env:FLOATING_LICENSE"" with timeout $FLOATING_LICENSE_TIMEOUT"
74+
# Store the exit code from the verify command
75+
$ACTIVATION_EXIT_CODE = $ACTIVATION_OUTPUT.ExitCode
76+
}
5377
else
5478
{
5579
#

dist/platforms/windows/return_license.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ Write-Output "# Return License #"
66
Write-Output "###########################"
77
Write-Output ""
88

9-
if (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}))
9+
if (($null -ne ${env:UNITY_LICENSING_SERVER}))
10+
{
11+
Write-Output "Returning floating license: ""$env:FLOATING_LICENSE"""
12+
Start-Process -FilePath "$Env:UNITY_PATH\Editor\Data\Resources\Licensing\Client\Unity.Licensing.Client.exe" `
13+
-ArgumentList "--return-floating ""$env:FLOATING_LICENSE"" " `
14+
-NoNewWindow `
15+
-Wait
16+
}
17+
18+
elseif (($null -ne ${env:UNITY_SERIAL}) -and ($null -ne ${env:UNITY_EMAIL}) -and ($null -ne ${env:UNITY_PASSWORD}))
1019
{
1120
#
1221
# SERIAL LICENSE MODE

src/model/docker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class Docker {
113113
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \
114114
--volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \
115115
--volume "${actionFolder}/platforms/windows":"c:/steps" \
116+
--volume "${actionFolder}/unity-config":"C:/ProgramData/Unity/config" \
116117
--volume "${actionFolder}/BlankProject":"c:/BlankProject" \
117118
--cpus=${dockerCpuLimit} \
118119
--memory=${dockerMemoryLimit} \

src/model/platform-validation/validate-windows.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import { BuildParameters } from '..';
44
class ValidateWindows {
55
public static validate(buildParameters: BuildParameters) {
66
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
7-
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
8-
throw new Error(`Unity email and password must be set for Windows based builds to
9-
authenticate the license. Make sure to set them inside UNITY_EMAIL
7+
8+
const { unityLicensingServer } = buildParameters;
9+
const hasLicensingCredentials = process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD;
10+
const hasValidLicensingStrategy = hasLicensingCredentials || unityLicensingServer;
11+
12+
if (!hasValidLicensingStrategy) {
13+
throw new Error(`Unity email and password or alternatively a Unity licensing server url must be set for
14+
Windows based builds to authenticate the license. Make sure to set them inside UNITY_EMAIL
1015
and UNITY_PASSWORD in Github Secrets and pass them into the environment.`);
1116
}
1217
}

0 commit comments

Comments
 (0)