Skip to content

Commit

Permalink
Merge 9413908 into 96cfb84
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKahr committed Nov 28, 2023
2 parents 96cfb84 + 9413908 commit 4169688
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 870 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ outputs:
description: 'The generated version used for the Unity build'
androidVersionCode:
description: 'The generated versionCode used for the Android Unity build'
engineExitCode:
description:
'Returns the exit code from the build scripts. This code is 0 if the build was successful. If there was an error
during activation, the code is from the activation step. If activation is successful, the code is from the project
build step.'
branding:
icon: 'box'
color: 'gray-dark'
Expand Down
709 changes: 0 additions & 709 deletions dist/default-build-script/Assembly-CSharp-Editor.csproj

This file was deleted.

10 changes: 0 additions & 10 deletions dist/default-build-script/ProjectSettings/XRSettings.asset

This file was deleted.

20 changes: 0 additions & 20 deletions dist/default-build-script/default-build-script.sln

This file was deleted.

This file was deleted.

88 changes: 31 additions & 57 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions dist/platforms/ubuntu/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash

# Ensure machine ID is randomized
dbus-uuidgen > /etc/machine-id && mkdir -p /var/lib/dbus/ && ln -sf /etc/machine-id /var/lib/dbus/machine-id
# Ensure machine ID is randomized for personal license activation
if [[ "$UNITY_SERIAL" = F* ]]; then
echo "Randomizing machine ID for personal license activation"
dbus-uuidgen > /etc/machine-id && mkdir -p /var/lib/dbus/ && ln -sf /etc/machine-id /var/lib/dbus/machine-id
fi

#
# Prepare Android SDK, if needed
Expand Down
7 changes: 4 additions & 3 deletions dist/platforms/ubuntu/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
echo "Activation successful"
break
else
echo "Activation failed, retrying in $delay seconds..."
sleep $delay

# Increment retry count
((retry_count++))

echo "::warning ::Activation failed, attempting retry #$retry_count"
echo "Activation failed, retrying in $delay seconds..."
sleep $delay

# Double the delay for the next iteration
delay=$((delay * 2))
fi
Expand Down
24 changes: 15 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,31 @@ async function runMain() {
const buildParameters = await BuildParameters.create();
const baseImage = new ImageTag(buildParameters);

let exitCode = -1;

if (buildParameters.providerStrategy === 'local') {
core.info('Building locally');
await PlatformSetup.setup(buildParameters, actionFolder);
if (process.platform === 'darwin') {
MacBuilder.run(actionFolder);
} else {
await Docker.run(baseImage.toString(), {
workspace,
actionFolder,
...buildParameters,
});
}
exitCode =
process.platform === 'darwin'
? await MacBuilder.run(actionFolder)
: await Docker.run(baseImage.toString(), {
workspace,
actionFolder,
...buildParameters,
});
} else {
await CloudRunner.run(buildParameters, baseImage.toString());
}

// Set output
await Output.setBuildVersion(buildParameters.buildVersion);
await Output.setAndroidVersionCode(buildParameters.androidVersionCode);
await Output.setEngineExitCode(exitCode);

if (exitCode !== 0) {
core.setFailed(`Build failed with exit code ${exitCode}`);
}
} catch (error) {
core.setFailed((error as Error).message);
}
Expand Down
9 changes: 7 additions & 2 deletions src/model/cloud-runner/providers/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ cp -a ${sharedFolder}. /github/workspace/cloud-runner-cache/
if (fs.existsSync(`${workspace}/cloud-runner-cache`)) {
await CloudRunnerSystem.Run(`ls ${workspace}/cloud-runner-cache && du -sh ${workspace}/cloud-runner-cache`);
}
await Docker.run(
const exitCode = await Docker.run(
image,
{ workspace, actionFolder, ...this.buildParameters },
false,
Expand All @@ -150,9 +150,14 @@ cp -a ${sharedFolder}. /github/workspace/cloud-runner-cache/
},
},
true,
false,
);

// Docker doesn't exit on fail now so adding this to ensure behavior is unchanged
// TODO: Is there a helpful way to consume the exit code or is it best to except
if (exitCode !== 0) {
throw new Error(`Build failed with exit code ${exitCode}`);
}

return myOutput;
}
}
Expand Down
20 changes: 8 additions & 12 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { execWithErrorCheck } from './exec-with-error-check';
import ImageEnvironmentFactory from './image-environment-factory';
import { existsSync, mkdirSync } from 'node:fs';
import path from 'node:path';
import { ExecOptions } from '@actions/exec';
import { ExecOptions, exec } from '@actions/exec';
import { DockerParameters, StringKeyValuePair } from './shared-types';

class Docker {
Expand All @@ -12,11 +11,9 @@ class Docker {
silent: boolean = false,
overrideCommands: string = '',
additionalVariables: StringKeyValuePair[] = [],
// eslint-disable-next-line unicorn/no-useless-undefined
options: ExecOptions | undefined = undefined,
options: ExecOptions = {},
entrypointBash: boolean = false,
errorWhenMissingUnityBuildResults: boolean = false,
) {
): Promise<number> {
let runCommand = '';
switch (process.platform) {
case 'linux':
Expand All @@ -25,12 +22,11 @@ class Docker {
case 'win32':
runCommand = this.getWindowsCommand(image, parameters);
}
if (options) {
options.silent = silent;
await execWithErrorCheck(runCommand, undefined, options, errorWhenMissingUnityBuildResults);
} else {
await execWithErrorCheck(runCommand, undefined, { silent }, errorWhenMissingUnityBuildResults);
}

options.silent = silent;
options.ignoreReturnCode = true;

return await exec(runCommand, undefined, options);
}

static getLinuxCommand(
Expand Down
29 changes: 0 additions & 29 deletions src/model/exec-with-error-check.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/model/mac-builder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { execWithErrorCheck } from './exec-with-error-check';
import { exec } from '@actions/exec';

class MacBuilder {
public static async run(actionFolder: string, silent: boolean = false) {
await execWithErrorCheck('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
public static async run(actionFolder: string, silent: boolean = false): Promise<number> {
return await exec('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
silent,
ignoreReturnCode: true,
});
}
}
Expand Down
Loading

0 comments on commit 4169688

Please sign in to comment.