Skip to content

Commit bbd713b

Browse files
authored
Fix pro activation (#602)
- Only randomize uuid for personal licenses - Add warning annotation for license activation retries - add `engineExitCode` output - repo/code cleanup
1 parent 96cfb84 commit bbd713b

File tree

16 files changed

+84
-870
lines changed

16 files changed

+84
-870
lines changed

action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ outputs:
261261
description: 'The generated version used for the Unity build'
262262
androidVersionCode:
263263
description: 'The generated versionCode used for the Android Unity build'
264+
engineExitCode:
265+
description:
266+
'Returns the exit code from the build scripts. This code is 0 if the build was successful. If there was an error
267+
during activation, the code is from the activation step. If activation is successful, the code is from the project
268+
build step.'
264269
branding:
265270
icon: 'box'
266271
color: 'gray-dark'

dist/default-build-script/Assembly-CSharp-Editor.csproj

-709
This file was deleted.

dist/default-build-script/ProjectSettings/XRSettings.asset

-10
This file was deleted.

dist/default-build-script/default-build-script.sln

-20
This file was deleted.

dist/default-build-script/default-build-script.sln.DotSettings

-3
This file was deleted.

dist/index.js

+31-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/ubuntu/entrypoint.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env bash
22

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

69
#
710
# Prepare Android SDK, if needed

dist/platforms/ubuntu/steps/activate.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
3535
echo "Activation successful"
3636
break
3737
else
38-
echo "Activation failed, retrying in $delay seconds..."
39-
sleep $delay
40-
4138
# Increment retry count
4239
((retry_count++))
4340

41+
echo "::warning ::Activation failed, attempting retry #$retry_count"
42+
echo "Activation failed, retrying in $delay seconds..."
43+
sleep $delay
44+
4445
# Double the delay for the next iteration
4546
delay=$((delay * 2))
4647
fi

src/index.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,31 @@ async function runMain() {
1919
const buildParameters = await BuildParameters.create();
2020
const baseImage = new ImageTag(buildParameters);
2121

22+
let exitCode = -1;
23+
2224
if (buildParameters.providerStrategy === 'local') {
2325
core.info('Building locally');
2426
await PlatformSetup.setup(buildParameters, actionFolder);
25-
if (process.platform === 'darwin') {
26-
MacBuilder.run(actionFolder);
27-
} else {
28-
await Docker.run(baseImage.toString(), {
29-
workspace,
30-
actionFolder,
31-
...buildParameters,
32-
});
33-
}
27+
exitCode =
28+
process.platform === 'darwin'
29+
? await MacBuilder.run(actionFolder)
30+
: await Docker.run(baseImage.toString(), {
31+
workspace,
32+
actionFolder,
33+
...buildParameters,
34+
});
3435
} else {
3536
await CloudRunner.run(buildParameters, baseImage.toString());
3637
}
3738

3839
// Set output
3940
await Output.setBuildVersion(buildParameters.buildVersion);
4041
await Output.setAndroidVersionCode(buildParameters.androidVersionCode);
42+
await Output.setEngineExitCode(exitCode);
43+
44+
if (exitCode !== 0) {
45+
core.setFailed(`Build failed with exit code ${exitCode}`);
46+
}
4147
} catch (error) {
4248
core.setFailed((error as Error).message);
4349
}

src/model/cloud-runner/providers/docker/index.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ cp -a ${sharedFolder}. /github/workspace/cloud-runner-cache/
133133
if (fs.existsSync(`${workspace}/cloud-runner-cache`)) {
134134
await CloudRunnerSystem.Run(`ls ${workspace}/cloud-runner-cache && du -sh ${workspace}/cloud-runner-cache`);
135135
}
136-
await Docker.run(
136+
const exitCode = await Docker.run(
137137
image,
138138
{ workspace, actionFolder, ...this.buildParameters },
139139
false,
@@ -150,9 +150,14 @@ cp -a ${sharedFolder}. /github/workspace/cloud-runner-cache/
150150
},
151151
},
152152
true,
153-
false,
154153
);
155154

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

src/model/docker.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { execWithErrorCheck } from './exec-with-error-check';
21
import ImageEnvironmentFactory from './image-environment-factory';
32
import { existsSync, mkdirSync } from 'node:fs';
43
import path from 'node:path';
5-
import { ExecOptions } from '@actions/exec';
4+
import { ExecOptions, exec } from '@actions/exec';
65
import { DockerParameters, StringKeyValuePair } from './shared-types';
76

87
class Docker {
@@ -12,11 +11,9 @@ class Docker {
1211
silent: boolean = false,
1312
overrideCommands: string = '',
1413
additionalVariables: StringKeyValuePair[] = [],
15-
// eslint-disable-next-line unicorn/no-useless-undefined
16-
options: ExecOptions | undefined = undefined,
14+
options: ExecOptions = {},
1715
entrypointBash: boolean = false,
18-
errorWhenMissingUnityBuildResults: boolean = false,
19-
) {
16+
): Promise<number> {
2017
let runCommand = '';
2118
switch (process.platform) {
2219
case 'linux':
@@ -25,12 +22,11 @@ class Docker {
2522
case 'win32':
2623
runCommand = this.getWindowsCommand(image, parameters);
2724
}
28-
if (options) {
29-
options.silent = silent;
30-
await execWithErrorCheck(runCommand, undefined, options, errorWhenMissingUnityBuildResults);
31-
} else {
32-
await execWithErrorCheck(runCommand, undefined, { silent }, errorWhenMissingUnityBuildResults);
33-
}
25+
26+
options.silent = silent;
27+
options.ignoreReturnCode = true;
28+
29+
return await exec(runCommand, undefined, options);
3430
}
3531

3632
static getLinuxCommand(

src/model/exec-with-error-check.ts

-29
This file was deleted.

src/model/mac-builder.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { execWithErrorCheck } from './exec-with-error-check';
1+
import { exec } from '@actions/exec';
22

33
class MacBuilder {
4-
public static async run(actionFolder: string, silent: boolean = false) {
5-
await execWithErrorCheck('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
4+
public static async run(actionFolder: string, silent: boolean = false): Promise<number> {
5+
return await exec('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
66
silent,
7+
ignoreReturnCode: true,
78
});
89
}
910
}

0 commit comments

Comments
 (0)