Skip to content

Commit a13443a

Browse files
authored
manualExit suppresses -quit, useful for buildMethods with async calls (#574)
* `manualExit` suppresses `-quit`, useful for buildMethods with async calls * Use boolean
1 parent 2190fd5 commit a13443a

File tree

8 files changed

+39
-2
lines changed

8 files changed

+39
-2
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ inputs:
3131
required: false
3232
default: ''
3333
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
34+
manualExit:
35+
required: false
36+
default: ''
37+
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
3438
customParameters:
3539
required: false
3640
default: ''

dist/index.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/platforms/ubuntu/steps/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ echo ""
119119

120120
unity-editor \
121121
-logfile /dev/stdout \
122-
-quit \
122+
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
123123
-customBuildName "$BUILD_NAME" \
124124
-projectPath "$UNITY_PROJECT_PATH" \
125125
-buildTarget "$BUILD_TARGET" \

src/model/build-parameters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class BuildParameters {
2929
public buildFile!: string;
3030
public buildMethod!: string;
3131
public buildVersion!: string;
32+
public manualExit!: boolean;
3233
public androidVersionCode!: string;
3334
public androidKeystoreName!: string;
3435
public androidKeystoreBase64!: string;
@@ -139,6 +140,7 @@ class BuildParameters {
139140
buildFile,
140141
buildMethod: Input.buildMethod,
141142
buildVersion,
143+
manualExit: Input.manualExit,
142144
androidVersionCode,
143145
androidKeystoreName: Input.androidKeystoreName,
144146
androidKeystoreBase64: Input.androidKeystoreBase64,

src/model/image-environment-factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class ImageEnvironmentFactory {
3737
{ name: 'BUILD_PATH', value: parameters.buildPath },
3838
{ name: 'BUILD_FILE', value: parameters.buildFile },
3939
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
40+
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
4041
{ name: 'VERSION', value: parameters.buildVersion },
4142
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
4243
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },

src/model/input.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ describe('Input', () => {
104104
});
105105
});
106106

107+
describe('manualExit', () => {
108+
it('returns the default value', () => {
109+
expect(Input.manualExit).toStrictEqual(false);
110+
});
111+
112+
it('returns true when string true is passed', () => {
113+
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
114+
expect(Input.manualExit).toStrictEqual(true);
115+
expect(spy).toHaveBeenCalledTimes(1);
116+
});
117+
118+
it('returns false when string false is passed', () => {
119+
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
120+
expect(Input.manualExit).toStrictEqual(false);
121+
expect(spy).toHaveBeenCalledTimes(1);
122+
});
123+
});
124+
107125
describe('versioningStrategy', () => {
108126
it('returns the default value', () => {
109127
expect(Input.versioningStrategy).toStrictEqual('Semantic');

src/model/input.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ class Input {
126126
return Input.getInput('buildMethod') || ''; // Processed in docker file
127127
}
128128

129+
static get manualExit(): boolean {
130+
const input = Input.getInput('manualExit') || false;
131+
132+
return input === 'true';
133+
}
134+
129135
static get customParameters(): string {
130136
return Input.getInput('customParameters') || '';
131137
}

0 commit comments

Comments
 (0)