Feature/support for unity licensing server linux (#468)
* Initial support for adding a UNITY_LICENSING_SERVER parameter to build parameters * Test to figure out what the working directory is of current bash script * Outputting current directory and using $ACTION_FOLDER * Add resources folder to mounted docker volumes. Used by activation script to copy over template file for unity licensing server * use awk instead of sed due to http characters breaking syntax * mkdir for unity config * Add -p flag to mkdir so parents are also created if missing * Initial work on returning floating license when using licensing server * Checking licensing server first for now, since serial is always set * Parse and save acquired floating license for use for returning after build * Clean up duplicate commands in activate.sh * Fixed running string as command, use it as input instead * Fixed cloud runner tests failing when using a ssh remote. * Clean up of test files and unnecessary logging * Moved process of generating services-config.json file from platform specific activate scripts to typescript * Fixed path
This commit is contained in:
60
dist/index.js
generated
vendored
60
dist/index.js
generated
vendored
@@ -231,23 +231,26 @@ class BuildParameters {
|
||||
// Todo - Don't use process.env directly, that's what the input model class is for.
|
||||
// ---
|
||||
let unitySerial = '';
|
||||
if (!process.env.UNITY_SERIAL && input_1.default.githubInputEnabled) {
|
||||
// No serial was present, so it is a personal license that we need to convert
|
||||
if (!process.env.UNITY_LICENSE) {
|
||||
throw new Error(`Missing Unity License File and no Serial was found. If this
|
||||
if (input_1.default.unityLicensingServer === '') {
|
||||
if (!process.env.UNITY_SERIAL && input_1.default.githubInputEnabled) {
|
||||
// No serial was present, so it is a personal license that we need to convert
|
||||
if (!process.env.UNITY_LICENSE) {
|
||||
throw new Error(`Missing Unity License File and no Serial was found. If this
|
||||
is a personal license, make sure to follow the activation
|
||||
steps and set the UNITY_LICENSE GitHub secret or enter a Unity
|
||||
serial number inside the UNITY_SERIAL GitHub secret.`);
|
||||
}
|
||||
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
||||
}
|
||||
else {
|
||||
unitySerial = process.env.UNITY_SERIAL;
|
||||
}
|
||||
unitySerial = this.getSerialFromLicenseFile(process.env.UNITY_LICENSE);
|
||||
}
|
||||
else {
|
||||
unitySerial = process.env.UNITY_SERIAL;
|
||||
}
|
||||
return {
|
||||
editorVersion,
|
||||
customImage: input_1.default.customImage,
|
||||
unitySerial,
|
||||
unityLicensingServer: input_1.default.unityLicensingServer,
|
||||
runnerTempPath: process.env.RUNNER_TEMP,
|
||||
targetPlatform: input_1.default.targetPlatform,
|
||||
projectPath: input_1.default.projectPath,
|
||||
@@ -4491,6 +4494,7 @@ class Docker {
|
||||
--volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \
|
||||
--volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \
|
||||
--volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \
|
||||
--volume "${actionFolder}/unity-config:/usr/share/unity3d/config/:z" \
|
||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||
${image} \
|
||||
@@ -4588,6 +4592,7 @@ class ImageEnvironmentFactory {
|
||||
{ name: 'UNITY_EMAIL', value: process.env.UNITY_EMAIL },
|
||||
{ name: 'UNITY_PASSWORD', value: process.env.UNITY_PASSWORD },
|
||||
{ name: 'UNITY_SERIAL', value: parameters.unitySerial },
|
||||
{ name: 'UNITY_LICENSING_SERVER', value: parameters.unityLicensingServer },
|
||||
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
|
||||
{ name: 'USYM_UPLOAD_AUTH_TOKEN', value: process.env.USYM_UPLOAD_AUTH_TOKEN },
|
||||
{ name: 'PROJECT_PATH', value: parameters.projectPath },
|
||||
@@ -4920,7 +4925,7 @@ class GitRepoReader {
|
||||
const value = (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
|
||||
cloud_runner_logger_1.default.log(`value ${value}`);
|
||||
console_1.assert(value.includes('github.com'));
|
||||
return value.split('github.com/')[1].split('.git')[0];
|
||||
return value.split('github.com')[1].split('.git')[0].slice(1);
|
||||
});
|
||||
}
|
||||
static GetBranch() {
|
||||
@@ -5145,6 +5150,9 @@ class Input {
|
||||
static get buildsPath() {
|
||||
return Input.getInput('buildsPath') || 'build';
|
||||
}
|
||||
static get unityLicensingServer() {
|
||||
return Input.getInput('unityLicensingServer') || '';
|
||||
}
|
||||
static get buildMethod() {
|
||||
return Input.getInput('buildMethod') || ''; // Processed in docker file
|
||||
}
|
||||
@@ -5342,6 +5350,25 @@ exports["default"] = Output;
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -5355,11 +5382,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const platform_setup_1 = __nccwpck_require__(2014);
|
||||
const validate_windows_1 = __importDefault(__nccwpck_require__(41563));
|
||||
class PlatformSetup {
|
||||
static setup(buildParameters, actionFolder) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
PlatformSetup.SetupShared(buildParameters, actionFolder);
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
validate_windows_1.default.validate(buildParameters);
|
||||
@@ -5372,6 +5402,17 @@ class PlatformSetup {
|
||||
}
|
||||
});
|
||||
}
|
||||
static SetupShared(buildParameters, actionFolder) {
|
||||
const servicesConfigPath = `${actionFolder}/unity-config/services-config.json`;
|
||||
const servicesConfigPathTemplate = `${servicesConfigPath}.template`;
|
||||
if (!fs_1.default.existsSync(servicesConfigPathTemplate)) {
|
||||
core.error(`Missing services config ${servicesConfigPathTemplate}`);
|
||||
return;
|
||||
}
|
||||
let servicesConfig = fs_1.default.readFileSync(servicesConfigPathTemplate).toString();
|
||||
servicesConfig = servicesConfig.replace('%URL%', buildParameters.unityLicensingServer);
|
||||
fs_1.default.writeFileSync(servicesConfigPath, servicesConfig);
|
||||
}
|
||||
}
|
||||
exports["default"] = PlatformSetup;
|
||||
|
||||
@@ -5465,6 +5506,7 @@ class SetupMac {
|
||||
process.env.ACTION_FOLDER = actionFolder;
|
||||
process.env.UNITY_VERSION = buildParameters.editorVersion;
|
||||
process.env.UNITY_SERIAL = buildParameters.unitySerial;
|
||||
process.env.UNITY_LICENSING_SERVER = buildParameters.unityLicensingServer;
|
||||
process.env.PROJECT_PATH = buildParameters.projectPath;
|
||||
process.env.BUILD_TARGET = buildParameters.targetPlatform;
|
||||
process.env.BUILD_NAME = buildParameters.buildName;
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
15
dist/platforms/ubuntu/steps/activate.sh
vendored
15
dist/platforms/ubuntu/steps/activate.sh
vendored
@@ -74,6 +74,21 @@ 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"
|
||||
|
||||
/opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable?
|
||||
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
|
||||
UNITY_EXIT_CODE=$?
|
||||
else
|
||||
#
|
||||
# NO LICENSE ACTIVATION STRATEGY MATCHED
|
||||
|
||||
@@ -4,7 +4,14 @@
|
||||
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
|
||||
#
|
||||
|
||||
7
dist/unity-config/services-config.json.template
vendored
Normal file
7
dist/unity-config/services-config.json.template
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"licensingServiceBaseUrl": "%URL%",
|
||||
"enableEntitlementLicensing": true,
|
||||
"enableFloatingApi": true,
|
||||
"clientConnectTimeoutSec": 5,
|
||||
"clientHandshakeTimeoutSec": 10
|
||||
}
|
||||
Reference in New Issue
Block a user