mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00

* 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
77 lines
3.7 KiB
TypeScript
77 lines
3.7 KiB
TypeScript
import { BuildParameters } from '..';
|
|
import { getUnityChangeset } from 'unity-changeset';
|
|
import { exec } from '@actions/exec';
|
|
import fs from 'fs';
|
|
|
|
class SetupMac {
|
|
static unityHubPath = `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"`;
|
|
|
|
public static async setup(buildParameters: BuildParameters, actionFolder: string) {
|
|
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}/Unity.app/Contents/MacOS/Unity`;
|
|
|
|
// Only install unity if the editor doesn't already exist
|
|
if (!fs.existsSync(unityEditorPath)) {
|
|
await SetupMac.installUnityHub();
|
|
await SetupMac.installUnity(buildParameters);
|
|
}
|
|
|
|
await SetupMac.setEnvironmentVariables(buildParameters, actionFolder);
|
|
}
|
|
|
|
private static async installUnityHub(silent = false) {
|
|
const command = 'brew install unity-hub';
|
|
if (!fs.existsSync(this.unityHubPath)) {
|
|
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
|
// a false error
|
|
const errorCode = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
|
if (errorCode) {
|
|
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static async installUnity(buildParameters: BuildParameters, silent = false) {
|
|
const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
|
|
const command = `${this.unityHubPath} -- --headless install \
|
|
--version ${buildParameters.editorVersion} \
|
|
--changeset ${unityChangeset.changeset} \
|
|
--module mac-il2cpp \
|
|
--childModules`;
|
|
|
|
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
|
// a false error
|
|
const errorCode = await exec(command, undefined, { silent, ignoreReturnCode: true });
|
|
if (errorCode) {
|
|
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
|
|
}
|
|
}
|
|
|
|
private static async setEnvironmentVariables(buildParameters: BuildParameters, actionFolder: string) {
|
|
// Need to set environment variables from here because we execute
|
|
// the scripts on the host for mac
|
|
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;
|
|
process.env.BUILD_PATH = buildParameters.buildPath;
|
|
process.env.BUILD_FILE = buildParameters.buildFile;
|
|
process.env.BUILD_METHOD = buildParameters.buildMethod;
|
|
process.env.VERSION = buildParameters.buildVersion;
|
|
process.env.ANDROID_VERSION_CODE = buildParameters.androidVersionCode;
|
|
process.env.ANDROID_KEYSTORE_NAME = buildParameters.androidKeystoreName;
|
|
process.env.ANDROID_KEYSTORE_BASE64 = buildParameters.androidKeystoreBase64;
|
|
process.env.ANDROID_KEYSTORE_PASS = buildParameters.androidKeystorePass;
|
|
process.env.ANDROID_KEYALIAS_NAME = buildParameters.androidKeyaliasName;
|
|
process.env.ANDROID_KEYALIAS_PASS = buildParameters.androidKeyaliasPass;
|
|
process.env.ANDROID_TARGET_SDK_VERSION = buildParameters.androidTargetSdkVersion;
|
|
process.env.ANDROID_SDK_MANAGER_PARAMETERS = buildParameters.androidSdkManagerParameters;
|
|
process.env.CUSTOM_PARAMETERS = buildParameters.customParameters;
|
|
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
|
|
}
|
|
}
|
|
|
|
export default SetupMac;
|