diff --git a/dist/resources/services-config.json.template b/dist/resources/services-config.json.template new file mode 100644 index 0000000..5a868f1 --- /dev/null +++ b/dist/resources/services-config.json.template @@ -0,0 +1,7 @@ +{ + "licensingServiceBaseUrl": "%URL%", + "enableEntitlementLicensing": true, + "enableFloatingApi": true, + "clientConnectTimeoutSec": 5, + "clientHandshakeTimeoutSec": 10 +} diff --git a/dist/steps/activate.sh b/dist/steps/activate.sh index 376b2bb..5ef0705 100755 --- a/dist/steps/activate.sh +++ b/dist/steps/activate.sh @@ -77,7 +77,26 @@ elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then # 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" + pushd /resources + cat services-config.json.template | tr -d '\r' | awk "{sub(/%URL%/,\"$UNITY_LICENSING_SERVER\")}1" > services-config.json + mkdir -p /usr/share/unity3d/config/ + mv services-config.json /usr/share/unity3d/config/ + /opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable? + UNITY_EXIT_CODE=$? + 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 + popd else # # NO LICENSE ACTIVATION STRATEGY MATCHED diff --git a/dist/steps/return_license.sh b/dist/steps/return_license.sh index 46f8120..db9cb54 100755 --- a/dist/steps/return_license.sh +++ b/dist/steps/return_license.sh @@ -4,7 +4,13 @@ echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." pushd "$ACTIVATE_LICENSE_PATH" -if [[ -n "$UNITY_SERIAL" ]]; then +if [[ -n "$UNITY_LICENSING_SERVER" ]]; then # + # + # Return any floating license used. + # + echo "Returning floating license: \"$FLOATING_LICENSE\"" + /opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --return-floating "$FLOATING_LICENSE" +elif [[ -n "$UNITY_SERIAL" ]]; then # # PROFESSIONAL (SERIAL) LICENSE MODE # @@ -17,6 +23,5 @@ if [[ -n "$UNITY_SERIAL" ]]; then -quit \ -returnlicense fi - # Return to previous working directory popd diff --git a/src/index.ts b/src/index.ts index 6463c53..f4b6287 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,6 +20,7 @@ async function run() { githubToken, checkName, chownFilesTo, + unityLicensingServer } = Input.getFromUser(); const baseImage = new ImageTag({ editorVersion, customImage }); const runnerTemporaryPath = process.env.RUNNER_TEMP; @@ -40,6 +41,7 @@ async function run() { githubToken, runnerTemporaryPath, chownFilesTo, + unityLicensingServer }); } finally { await Output.setArtifactsPath(artifactsPath); diff --git a/src/model/docker.ts b/src/model/docker.ts index fb250c6..cae9722 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -34,6 +34,7 @@ const Docker = { githubToken, runnerTemporaryPath, chownFilesTo, + unityLicensingServer } = parameters; const githubHome = path.join(runnerTemporaryPath, '_github_home'); @@ -52,6 +53,7 @@ const Docker = { --env UNITY_EMAIL \ --env UNITY_PASSWORD \ --env UNITY_SERIAL \ + --env UNITY_LICENSING_SERVER="${unityLicensingServer}" \ --env UNITY_VERSION="${editorVersion}" \ --env PROJECT_PATH="${projectPath}" \ --env CUSTOM_PARAMETERS="${customParameters}" \ @@ -82,6 +84,7 @@ const Docker = { --volume "${workspace}:/github/workspace:z" \ --volume "${actionFolder}/steps:/steps:z" \ --volume "${actionFolder}/entrypoint.sh:/entrypoint.sh:z" \ + --volume "${actionFolder}/resources:/resources:z" \ ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ ${ sshAgent ? `--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro` : '' @@ -108,6 +111,7 @@ const Docker = { githubToken, runnerTemporaryPath, chownFilesTo, + unityLicensingServer } = parameters; const githubHome = path.join(runnerTemporaryPath, '_github_home'); @@ -126,6 +130,7 @@ const Docker = { --env UNITY_EMAIL \ --env UNITY_PASSWORD \ --env UNITY_SERIAL \ + --env UNITY_LICENSING_SERVER="${unityLicensingServer}" \ --env UNITY_VERSION="${editorVersion}" \ --env PROJECT_PATH="${projectPath}" \ --env CUSTOM_PARAMETERS="${customParameters}" \ diff --git a/src/model/input.ts b/src/model/input.ts index e71dd3d..f093081 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -17,6 +17,7 @@ const Input = { const unityVersion = getInput('unityVersion') || 'auto'; const customImage = getInput('customImage') || ''; const rawProjectPath = getInput('projectPath') || '.'; + const unityLicensingServer = getInput('unityLicensingServer') || ''; const customParameters = getInput('customParameters') || ''; const testMode = (getInput('testMode') || 'all').toLowerCase(); const coverageOptions = getInput('coverageOptions') || ''; @@ -67,6 +68,7 @@ const Input = { githubToken, checkName, chownFilesTo, + unityLicensingServer }; }, };