Additional Fixes and Improvements (#596)

- Windows now exits with the proper exit codes. This mirrors Ubuntu behavior properly now and means we do not need the error parsing logic to handle error conditions which means we should be back to v2 behavior.
- Allow customizing image registry/image version
- Only create the licensing directory on Mac if it doesn't already exist. Don't delete the folder on build complete. This means builds nominally shouldn't need sudo permissions, very useful for self-hosted runners.
- Pick correct architecture when installing macos editor to support both x86 and arm-based systems (Credit @dcvz)
This commit is contained in:
Andrew Kahr
2023-11-15 06:17:55 -08:00
committed by GitHub
parent caa0a81b47
commit 2afd9cd86f
13 changed files with 143 additions and 44 deletions

View File

@@ -47,7 +47,10 @@ class SetupMac {
// 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 });
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.`);
}
@@ -64,7 +67,9 @@ class SetupMac {
private static async getLatestUnityHubVersion(): Promise<string> {
// Need to check if the latest version available is the same as the one we have cached
const hubVersionCommand = `/bin/bash -c "brew info unity-hub | grep -o '[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+'"`;
const result = await getExecOutput(hubVersionCommand, undefined, { silent: true });
const result = await getExecOutput(hubVersionCommand, undefined, {
silent: true,
});
if (result.exitCode === 0 && result.stdout !== '') {
return result.stdout;
}
@@ -72,6 +77,23 @@ class SetupMac {
return '';
}
private static getArchitectureParameters(): string[] {
const architectureArgument = [];
switch (process.arch) {
case 'x64':
architectureArgument.push('--architecture', 'x86_64');
break;
case 'arm64':
architectureArgument.push('--architecture', 'arm64');
break;
default:
throw new Error(`Unsupported architecture: ${process.arch}.`);
}
return architectureArgument;
}
private static getModuleParametersForTargetPlatform(targetPlatform: string): string[] {
const moduleArgument = [];
switch (targetPlatform) {
@@ -111,6 +133,7 @@ class SetupMac {
const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
const moduleArguments = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);
const architectureArguments = SetupMac.getArchitectureParameters();
const execArguments: string[] = [
'--',
@@ -119,12 +142,16 @@ class SetupMac {
...['--version', buildParameters.editorVersion],
...['--changeset', unityChangeset.changeset],
...moduleArguments,
...architectureArguments,
'--childModules',
];
// Ignoring return code because the log seems to overflow the internal buffer which triggers
// a false error
const errorCode = await exec(this.unityHubExecPath, execArguments, { silent, ignoreReturnCode: true });
const errorCode = await exec(this.unityHubExecPath, execArguments, {
silent,
ignoreReturnCode: true,
});
if (errorCode) {
throw new Error(`There was an error installing the Unity Editor. See logs above for details.`);
}