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

Support Multiple License Products when using Unity Licensing Server #282

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ inputs:
required: false
default: ''
description: 'Url to a unity license server for acquiring floating licenses.'
unityLicensingProductIds:
required: false
default: ''
description:
'Comma separated list of license product identifiers to request licenses for from the license server. Not setting
this will request the default license product configured on the licensing server. Only applicable if
unityLicensingServer is set.'
containerRegistryRepository:
required: false
default: 'unityci/editor'
Expand Down
11 changes: 8 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/unity-config/services-config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"enableEntitlementLicensing": true,
"enableFloatingApi": true,
"clientConnectTimeoutSec": 5,
"clientHandshakeTimeoutSec": 10
"clientHandshakeTimeoutSec": 10,
"toolset": "%LICENSE_PRODUCT_IDS%"
}
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export async function run() {
dockerMemoryLimit,
dockerIsolationMode,
unityLicensingServer,
unityLicensingProductIds,
runAsHostUser,
containerRegistryRepository,
containerRegistryImageVersion,
Expand Down Expand Up @@ -66,6 +67,7 @@ export async function run() {
dockerMemoryLimit,
dockerIsolationMode,
unityLicensingServer,
unityLicensingProductIds,
runAsHostUser,
unitySerial,
...runnerContext,
Expand Down
6 changes: 5 additions & 1 deletion src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const Docker = {
let runCommand = '';

if (parameters.unityLicensingServer !== '') {
LicensingServerSetup.Setup(parameters.unityLicensingServer, parameters.actionFolder);
LicensingServerSetup.Setup(
parameters.unityLicensingServer,
parameters.actionFolder,
parameters.unityLicensingProductIds,
);
}

switch (process.platform) {
Expand Down
1 change: 1 addition & 0 deletions src/model/image-environment-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ImageEnvironmentFactory {
name: 'UNITY_LICENSING_SERVER',
value: parameters.unityLicensingServer,
},
{ name: 'UNITY_LICENSING_PRODUCT_IDS', value: parameters.unityLicensingProductIds },
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{
name: 'USYM_UPLOAD_AUTH_TOKEN',
Expand Down
2 changes: 2 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Input {
const customImage = getInput('customImage') || '';
const rawProjectPath = getInput('projectPath') || '.';
const unityLicensingServer = getInput('unityLicensingServer') || '';
const unityLicensingProductIds = getInput('unityLicensingProductIds') || '';
const unityLicense = getInput('unityLicense') || (process.env['UNITY_LICENSE'] ?? '');
let unitySerial = process.env['UNITY_SERIAL'] ?? '';
const customParameters = getInput('customParameters') || '';
Expand Down Expand Up @@ -239,6 +240,7 @@ class Input {
dockerMemoryLimit,
dockerIsolationMode,
unityLicensingServer,
unityLicensingProductIds,
runAsHostUser,
containerRegistryRepository,
containerRegistryImageVersion,
Expand Down
7 changes: 6 additions & 1 deletion src/model/licensing-server-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import fs from 'fs';

class LicensingServerSetup {
public static Setup(unityLicensingServer, actionFolder: string) {
public static Setup(
unityLicensingServer,
actionFolder: string,
unityLicensingProductIds: string,
) {
const servicesConfigPath = `${actionFolder}/unity-config/services-config.json`;
const servicesConfigPathTemplate = `${servicesConfigPath}.template`;
if (!fs.existsSync(servicesConfigPathTemplate)) {
Expand All @@ -13,6 +17,7 @@ class LicensingServerSetup {

let servicesConfig = fs.readFileSync(servicesConfigPathTemplate).toString();
servicesConfig = servicesConfig.replace('%URL%', unityLicensingServer);
servicesConfig = servicesConfig.replace('%LICENSE_PRODUCT_IDS%', unityLicensingProductIds);
fs.writeFileSync(servicesConfigPath, servicesConfig);
}
}
Expand Down