Skip to content

Commit

Permalink
manualExit suppresses -quit, useful for buildMethods with async c…
Browse files Browse the repository at this point in the history
…alls (#574)

* `manualExit` suppresses `-quit`, useful for buildMethods with async calls

* Use boolean
  • Loading branch information
tobyspark authored Sep 20, 2023
1 parent 2190fd5 commit a13443a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ inputs:
required: false
default: ''
description: 'Path to a Namespace.Class.StaticMethod to run to perform the build.'
manualExit:
required: false
default: ''
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
customParameters:
required: false
default: ''
Expand Down
6 changes: 6 additions & 0 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.

2 changes: 1 addition & 1 deletion dist/platforms/ubuntu/steps/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ echo ""

unity-editor \
-logfile /dev/stdout \
-quit \
$( [ "${MANUAL_EXIT}" == "true" ] || echo "-quit" ) \
-customBuildName "$BUILD_NAME" \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \
Expand Down
2 changes: 2 additions & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BuildParameters {
public buildFile!: string;
public buildMethod!: string;
public buildVersion!: string;
public manualExit!: boolean;
public androidVersionCode!: string;
public androidKeystoreName!: string;
public androidKeystoreBase64!: string;
Expand Down Expand Up @@ -139,6 +140,7 @@ class BuildParameters {
buildFile,
buildMethod: Input.buildMethod,
buildVersion,
manualExit: Input.manualExit,
androidVersionCode,
androidKeystoreName: Input.androidKeystoreName,
androidKeystoreBase64: Input.androidKeystoreBase64,
Expand Down
1 change: 1 addition & 0 deletions src/model/image-environment-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ImageEnvironmentFactory {
{ name: 'BUILD_PATH', value: parameters.buildPath },
{ name: 'BUILD_FILE', value: parameters.buildFile },
{ name: 'BUILD_METHOD', value: parameters.buildMethod },
{ name: 'MANUAL_EXIT', value: parameters.manualExit },
{ name: 'VERSION', value: parameters.buildVersion },
{ name: 'ANDROID_VERSION_CODE', value: parameters.androidVersionCode },
{ name: 'ANDROID_KEYSTORE_NAME', value: parameters.androidKeystoreName },
Expand Down
18 changes: 18 additions & 0 deletions src/model/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ describe('Input', () => {
});
});

describe('manualExit', () => {
it('returns the default value', () => {
expect(Input.manualExit).toStrictEqual(false);
});

it('returns true when string true is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
expect(Input.manualExit).toStrictEqual(true);
expect(spy).toHaveBeenCalledTimes(1);
});

it('returns false when string false is passed', () => {
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
expect(Input.manualExit).toStrictEqual(false);
expect(spy).toHaveBeenCalledTimes(1);
});
});

describe('versioningStrategy', () => {
it('returns the default value', () => {
expect(Input.versioningStrategy).toStrictEqual('Semantic');
Expand Down
6 changes: 6 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ class Input {
return Input.getInput('buildMethod') || ''; // Processed in docker file
}

static get manualExit(): boolean {
const input = Input.getInput('manualExit') || false;

return input === 'true';
}

static get customParameters(): string {
return Input.getInput('customParameters') || '';
}
Expand Down

0 comments on commit a13443a

Please sign in to comment.