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

* Add intial framework for macos builds. Test install editor * Fix unity hub path space * Single quote space in path * Escape space character * More backslashes * Move to bash scripts for setup * Add path to command args * Different command to run shell script * Use full path to scripts * Unpack changeset value and fix missing escape characters * Print changeset * More debug * Remove debug * Fix script paths * Printenv debug * Write environment variables to file to read in bash script * Debug file write * More debug * Fix missing await * Move back to process.env * Fix path typo * Add missing flags * Make directory for license activation * Add missing sudo * Give permissions to license folder * Fix path issues * Add build tests * Try ts setup again * Try quoting path * Further migrate mac scripts to align with linux scripts * print pwd * Fix changeset and remove unneeded env vars * Ignore return code * fix missing current directory * Fix project path * pwd * Remove project path * Revert to cwd being the workspace folder and pass action folder as an env variable. * Add blank project to use for activation * Add blank project path * Fix build tests * Don't rebuild library on windows * Fix project path windows * Fix platform specific workspace env variable * Fix incorrect variable name * Update .github/workflows/mac-build-tests.yml Co-authored-by: Webber Takken <webber.nl@gmail.com> * Update .github/workflows/mac-build-tests.yml Co-authored-by: Webber Takken <webber.nl@gmail.com> * Update dist/BlankProject/Packages/packages-lock.json Co-authored-by: Webber Takken <webber.nl@gmail.com> * Update src/model/platform-setup/setup-mac.ts Co-authored-by: Webber Takken <webber.nl@gmail.com> * Update src/model/platform-setup/setup-mac.ts Co-authored-by: Webber Takken <webber.nl@gmail.com> * Fix formatting Co-authored-by: Webber Takken <webber.nl@gmail.com>
76 lines
3.6 KiB
TypeScript
76 lines
3.6 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.version}/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.version);
|
|
const command = `${this.unityHubPath} -- --headless install \
|
|
--version ${buildParameters.version} \
|
|
--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.version;
|
|
process.env.UNITY_SERIAL = buildParameters.unitySerial;
|
|
process.env.PROJECT_PATH = buildParameters.projectPath;
|
|
process.env.BUILD_TARGET = buildParameters.platform;
|
|
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;
|