Ensure serial is prioritized

This commit is contained in:
Andrew Kahr 2023-11-05 23:59:27 -08:00
parent 7afabe74da
commit b20286a361
7 changed files with 29 additions and 67 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -4,64 +4,13 @@
echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory."
pushd "$ACTIVATE_LICENSE_PATH" 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 # SERIAL 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
# #
# This will activate unity, using the activating process. # This will activate unity, using the activating process.
# #
# Note: This is the preferred way for PROFESSIONAL LICENSES. echo "Requesting activation"
#
echo "Requesting activation (professional license)"
# Activate license # Activate license
unity-editor \ 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" /opt/unity/Editor/Data/Resources/Licensing/Client/Unity.Licensing.Client --return-floating "$FLOATING_LICENSE"
elif [[ -n "$UNITY_SERIAL" ]]; then elif [[ -n "$UNITY_SERIAL" ]]; then
# #
# PROFESSIONAL (SERIAL) LICENSE MODE # SERIAL LICENSE MODE
# #
# This will return the license that is currently in use. # 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 GitHub from './github';
import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options'; import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options';
import CloudRunner from './cloud-runner/cloud-runner'; import CloudRunner from './cloud-runner/cloud-runner';
import * as core from '@actions/core';
class BuildParameters { class BuildParameters {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
@ -127,6 +128,7 @@ class BuildParameters {
); );
} }
unitySerial = this.getSerialFromLicenseFile(Input.unityLicense); unitySerial = this.getSerialFromLicenseFile(Input.unityLicense);
core.setSecret(unitySerial);
} else { } else {
unitySerial = Input.unitySerial!; unitySerial = Input.unitySerial!;
} }

View File

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

View File

@ -1,4 +1,3 @@
import { ReadLicense } from './input-readers/test-license-reader';
import { DockerParameters, StringKeyValuePair } from './shared-types'; import { DockerParameters, StringKeyValuePair } from './shared-types';
class ImageEnvironmentFactory { class ImageEnvironmentFactory {
@ -23,14 +22,18 @@ class ImageEnvironmentFactory {
public static getEnvironmentVariables(parameters: DockerParameters, additionalVariables: StringKeyValuePair[] = []) { public static getEnvironmentVariables(parameters: DockerParameters, additionalVariables: StringKeyValuePair[] = []) {
let environmentVariables: 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_EMAIL', value: process.env.UNITY_EMAIL },
{ name: 'UNITY_PASSWORD', value: process.env.UNITY_PASSWORD }, { name: 'UNITY_PASSWORD', value: process.env.UNITY_PASSWORD },
{ name: 'UNITY_SERIAL', value: parameters.unitySerial }, { 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: '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: 'PROJECT_PATH', value: parameters.projectPath },
{ name: 'BUILD_TARGET', value: parameters.targetPlatform }, { name: 'BUILD_TARGET', value: parameters.targetPlatform },
{ name: 'BUILD_NAME', value: parameters.buildName }, { name: 'BUILD_NAME', value: parameters.buildName },
@ -41,12 +44,21 @@ class ImageEnvironmentFactory {
{ name: 'VERSION', value: parameters.buildVersion }, { name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode }, { name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName }, { 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_KEYSTORE_PASS', value: parameters.androidKeystorePass },
{ name: 'ANDROID_KEYALIAS_NAME', value: parameters.androidKeyaliasName }, { name: 'ANDROID_KEYALIAS_NAME', value: parameters.androidKeyaliasName },
{ name: 'ANDROID_KEYALIAS_PASS', value: parameters.androidKeyaliasPass }, { 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_EXPORT_TYPE', value: parameters.androidExportType },
{ name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType }, { name: 'ANDROID_SYMBOL_TYPE', value: parameters.androidSymbolType },
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters }, { 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; return environmentVariables;
} }