Skip to content

Commit

Permalink
Add licensingProductIds param & update services-config template
Browse files Browse the repository at this point in the history
Add licensingProductIds param & update services-config template
  • Loading branch information
ejnarvala authored Aug 7, 2024
2 parents 05a00ef + 119946d commit 90d8a2d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
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
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

0 comments on commit 90d8a2d

Please sign in to comment.