Ensure serial is prioritized

pull/590/head
Andrew Kahr 2023-11-05 23:59:27 -08:00
parent 7afabe74da
commit b20286a361
7 changed files with 79 additions and 107 deletions

88
dist/index.js generated vendored
View File

@ -201,6 +201,29 @@ exports["default"] = AndroidVersioning;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
@ -219,6 +242,7 @@ const cli_1 = __nccwpck_require__(55651);
const github_1 = __importDefault(__nccwpck_require__(83654));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
const core = __importStar(__nccwpck_require__(42186));
class BuildParameters {
static shouldUseRetainedWorkspaceMode(buildParameters) {
return buildParameters.maxRetainedWorkspaces > 0 && cloud_runner_1.default.lockedWorkspace !== ``;
@ -251,6 +275,7 @@ class BuildParameters {
serial number inside the UNITY_SERIAL GitHub secret.`);
}
unitySerial = this.getSerialFromLicenseFile(input_1.default.unityLicense);
core.setSecret(unitySerial);
}
else {
unitySerial = input_1.default.unitySerial;
@ -5901,7 +5926,6 @@ class Docker {
--workdir ${dockerWorkspacePath} \
--rm \
${image_environment_factory_1.default.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=${dockerWorkspacePath} \
--env GIT_CONFIG_EXTENSIONS \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
@ -5926,12 +5950,11 @@ class Docker {
"${overrideCommands !== '' ? overrideCommands : `/entrypoint.sh`}"`;
}
static getWindowsCommand(image, parameters) {
const { workspace, actionFolder, unitySerial, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerIsolationMode, } = parameters;
const { workspace, actionFolder, gitPrivateToken, dockerWorkspacePath, dockerCpuLimit, dockerMemoryLimit, dockerIsolationMode, } = parameters;
return `docker run \
--workdir c:${dockerWorkspacePath} \
--rm \
${image_environment_factory_1.default.getEnvVarString(parameters)} \
--env UNITY_SERIAL="${unitySerial}" \
--env GITHUB_WORKSPACE=c:${dockerWorkspacePath} \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
--volume "${workspace}":"c:${dockerWorkspacePath}" \
@ -6244,12 +6267,11 @@ exports["default"] = GitHub;
/***/ }),
/***/ 25145:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
const test_license_reader_1 = __nccwpck_require__(13963);
class ImageEnvironmentFactory {
static getEnvVarString(parameters, additionalVariables = []) {
const environmentVariables = ImageEnvironmentFactory.getEnvironmentVariables(parameters, additionalVariables);
@ -6269,14 +6291,18 @@ class ImageEnvironmentFactory {
}
static getEnvironmentVariables(parameters, additionalVariables = []) {
let environmentVariables = [
{ name: 'UNITY_LICENSE', value: process.env.UNITY_LICENSE || (0, test_license_reader_1.ReadLicense)() },
{ name: 'UNITY_LICENSE_FILE', value: process.env.UNITY_LICENSE_FILE },
{ 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_LICENSING_SERVER',
value: parameters.unityLicensingServer,
},
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{ name: 'USYM_UPLOAD_AUTH_TOKEN', value: process.env.USYM_UPLOAD_AUTH_TOKEN },
{
name: 'USYM_UPLOAD_AUTH_TOKEN',
value: process.env.USYM_UPLOAD_AUTH_TOKEN,
},
{ name: 'PROJECT_PATH', value: parameters.projectPath },
{ name: 'BUILD_TARGET', value: parameters.targetPlatform },
{ name: 'BUILD_NAME', value: parameters.buildName },
@ -6287,12 +6313,21 @@ class ImageEnvironmentFactory {
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
{ name: 'ANDROID_KEYSTORE_BASE64', value: parameters.androidKeystoreBase64 },
{
name: 'ANDROID_KEYSTORE_BASE64',
value: parameters.androidKeystoreBase64,
},
{ name: 'ANDROID_KEYSTORE_PASS', value: parameters.androidKeystorePass },
{ name: 'ANDROID_KEYALIAS_NAME', value: parameters.androidKeyaliasName },
{ name: 'ANDROID_KEYALIAS_PASS', value: parameters.androidKeyaliasPass },
{ name: 'ANDROID_TARGET_SDK_VERSION', value: parameters.androidTargetSdkVersion },
{ name: 'ANDROID_SDK_MANAGER_PARAMETERS', value: parameters.androidSdkManagerParameters },
{
name: 'ANDROID_TARGET_SDK_VERSION',
value: parameters.androidTargetSdkVersion,
},
{
name: 'ANDROID_SDK_MANAGER_PARAMETERS',
value: parameters.androidSdkManagerParameters,
},
{ name: 'ANDROID_EXPORT_TYPE', value: parameters.androidExportType },
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
@ -6324,8 +6359,9 @@ class ImageEnvironmentFactory {
}
}
}
if (parameters.sshAgent)
if (parameters.sshAgent) {
environmentVariables.push({ name: 'SSH_AUTH_SOCK', value: '/ssh-agent' });
}
return environmentVariables;
}
}
@ -6678,32 +6714,6 @@ class GithubCliReader {
exports.GithubCliReader = GithubCliReader;
/***/ }),
/***/ 13963:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ReadLicense = void 0;
const node_path_1 = __importDefault(__nccwpck_require__(49411));
const node_fs_1 = __importDefault(__nccwpck_require__(87561));
const yaml_1 = __importDefault(__nccwpck_require__(44083));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(66965));
function ReadLicense() {
if (cloud_runner_options_1.default.providerStrategy === 'local') {
return '';
}
const pipelineFile = node_path_1.default.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);
return node_fs_1.default.existsSync(pipelineFile) ? yaml_1.default.parse(node_fs_1.default.readFileSync(pipelineFile, 'utf8')).env.UNITY_LICENSE : '';
}
exports.ReadLicense = ReadLicense;
/***/ }),
/***/ 91933:

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -4,64 +4,13 @@
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
pushd "$ACTIVATE_LICENSE_PATH"
if [[ -n "$UNITY_LICENSE" ]] || [[ -n "$UNITY_LICENSE_FILE" ]]; then
if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
#
# PERSONAL LICENSE MODE
#
# This will activate Unity, using a license file
#
# Note that this is the ONLY WAY for PERSONAL LICENSES in 2020.
# * See for more details: https://gitlab.com/gableroux/unity3d-gitlab-ci-example/issues/5#note_72815478
#
# The license file can be acquired using `webbertakken/request-manual-activation-file` action.
echo "Requesting activation (personal license)"
# Set the license file path
FILE_PATH=UnityLicenseFile.ulf
if [[ -n "$UNITY_LICENSE" ]]; then
# Copy license file from Github variables
echo "$UNITY_LICENSE" | tr -d '\r' > $FILE_PATH
elif [[ -n "$UNITY_LICENSE_FILE" ]]; then
# Copy license file from file system
cat "$UNITY_LICENSE_FILE" | tr -d '\r' > $FILE_PATH
fi
# Activate license
ACTIVATION_OUTPUT=$(unity-editor \
-logFile /dev/stdout \
-quit \
-manualLicenseFile $FILE_PATH)
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
# The exit code for personal activation is always 1;
# Determine whether activation was successful.
#
# Successful output should include the following:
#
# "LICENSE SYSTEM [2020120 18:51:20] Next license update check is after 2019-11-25T18:23:38"
#
ACTIVATION_SUCCESSFUL=$(echo $ACTIVATION_OUTPUT | grep 'Next license update check is after' | wc -l)
# Set exit code to 0 if activation was successful
if [[ $ACTIVATION_SUCCESSFUL -eq 1 ]]; then
UNITY_EXIT_CODE=0
fi;
# Remove license file
rm -f $FILE_PATH
elif [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
#
# PROFESSIONAL (SERIAL) LICENSE MODE
# SERIAL LICENSE MODE
#
# This will activate unity, using the activating process.
#
# Note: This is the preferred way for PROFESSIONAL LICENSES.
#
echo "Requesting activation (professional license)"
echo "Requesting activation"
# Activate license
unity-editor \

View File

@ -13,7 +13,7 @@ if [[ -n "$UNITY_LICENSING_SERVER" ]]; then #
/opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --return-floating "$FLOATING_LICENSE"
elif [[ -n "$UNITY_SERIAL" ]]; then
#
# PROFESSIONAL (SERIAL) LICENSE MODE
# SERIAL LICENSE MODE
#
# This will return the license that is currently in use.
#

View File

@ -12,6 +12,7 @@ import { Cli } from './cli/cli';
import GitHub from './github';
import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options';
import CloudRunner from './cloud-runner/cloud-runner';
import * as core from '@actions/core';
class BuildParameters {
// eslint-disable-next-line no-undef
@ -127,6 +128,7 @@ class BuildParameters {
);
}
unitySerial = this.getSerialFromLicenseFile(Input.unityLicense);
core.setSecret(unitySerial);
} else {
unitySerial = Input.unitySerial!;
}

View File

@ -62,7 +62,6 @@ class Docker {
--workdir ${dockerWorkspacePath} \
--rm \
${ImageEnvironmentFactory.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=${dockerWorkspacePath} \
--env GIT_CONFIG_EXTENSIONS \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
@ -93,7 +92,6 @@ class Docker {
const {
workspace,
actionFolder,
unitySerial,
gitPrivateToken,
dockerWorkspacePath,
dockerCpuLimit,
@ -105,7 +103,6 @@ class Docker {
--workdir c:${dockerWorkspacePath} \
--rm \
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
--env UNITY_SERIAL="${unitySerial}" \
--env GITHUB_WORKSPACE=c:${dockerWorkspacePath} \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
--volume "${workspace}":"c:${dockerWorkspacePath}" \

View File

@ -1,4 +1,3 @@
import { ReadLicense } from './input-readers/test-license-reader';
import { DockerParameters, StringKeyValuePair } from './shared-types';
class ImageEnvironmentFactory {
@ -23,14 +22,18 @@ class ImageEnvironmentFactory {
public static getEnvironmentVariables(parameters: DockerParameters, additionalVariables: StringKeyValuePair[] = []) {
let environmentVariables: StringKeyValuePair[] = [
{ name: 'UNITY_LICENSE', value: process.env.UNITY_LICENSE || ReadLicense() },
{ name: 'UNITY_LICENSE_FILE', value: process.env.UNITY_LICENSE_FILE },
{ 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_LICENSING_SERVER',
value: parameters.unityLicensingServer,
},
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
{ name: 'USYM_UPLOAD_AUTH_TOKEN', value: process.env.USYM_UPLOAD_AUTH_TOKEN },
{
name: 'USYM_UPLOAD_AUTH_TOKEN',
value: process.env.USYM_UPLOAD_AUTH_TOKEN,
},
{ name: 'PROJECT_PATH', value: parameters.projectPath },
{ name: 'BUILD_TARGET', value: parameters.targetPlatform },
{ name: 'BUILD_NAME', value: parameters.buildName },
@ -41,12 +44,21 @@ class ImageEnvironmentFactory {
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
{ name: 'ANDROID_KEYSTORE_BASE64', value: parameters.androidKeystoreBase64 },
{
name: 'ANDROID_KEYSTORE_BASE64',
value: parameters.androidKeystoreBase64,
},
{ name: 'ANDROID_KEYSTORE_PASS', value: parameters.androidKeystorePass },
{ name: 'ANDROID_KEYALIAS_NAME', value: parameters.androidKeyaliasName },
{ name: 'ANDROID_KEYALIAS_PASS', value: parameters.androidKeyaliasPass },
{ name: 'ANDROID_TARGET_SDK_VERSION', value: parameters.androidTargetSdkVersion },
{ name: 'ANDROID_SDK_MANAGER_PARAMETERS', value: parameters.androidSdkManagerParameters },
{
name: 'ANDROID_TARGET_SDK_VERSION',
value: parameters.androidTargetSdkVersion,
},
{
name: 'ANDROID_SDK_MANAGER_PARAMETERS',
value: parameters.androidSdkManagerParameters,
},
{ name: 'ANDROID_EXPORT_TYPE', value: parameters.androidExportType },
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
@ -86,7 +98,9 @@ class ImageEnvironmentFactory {
}
}
}
if (parameters.sshAgent) environmentVariables.push({ name: 'SSH_AUTH_SOCK', value: '/ssh-agent' });
if (parameters.sshAgent) {
environmentVariables.push({ name: 'SSH_AUTH_SOCK', value: '/ssh-agent' });
}
return environmentVariables;
}