From 37ce35f1a5c59ebcff6818579f425b63f705c81a Mon Sep 17 00:00:00 2001 From: frostebite Date: Wed, 6 May 2026 22:05:23 +0100 Subject: [PATCH] feat: add linux64RemoveExecutableExtension parameter (default: false) Adds configurable control over the `.x86_64` file extension for StandaloneLinux64 builds. Default is `false` (keep the extension), matching Unity's native behavior. Set `linux64RemoveExecutableExtension: true` to restore the extensionless behavior from v4. Rebased from kitlith's original PR #726. Default flipped for v5. Closes #722 Co-Authored-By: kitlith Co-Authored-By: Claude Opus 4.6 (1M context) --- action.yml | 5 +++++ src/model/build-parameters.test.ts | 19 +++++++++++-------- src/model/build-parameters.ts | 12 +++++++++++- src/model/input.test.ts | 18 ++++++++++++++++++ src/model/input.ts | 6 ++++++ 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 294577e5..d34f6dbc 100644 --- a/action.yml +++ b/action.yml @@ -178,6 +178,11 @@ inputs: default: 'false' required: false description: 'Skip the activation/deactivation of Unity. This assumes Unity is already activated.' + linux64RemoveExecutableExtension: + default: 'false' + required: false + description: + 'When building for StandaloneLinux64, remove the default file extension of `.x86_64`. Set to true to restore the extensionless behavior from v4.' outputs: volume: diff --git a/src/model/build-parameters.test.ts b/src/model/build-parameters.test.ts index e669bcad..c7f4470d 100644 --- a/src/model/build-parameters.test.ts +++ b/src/model/build-parameters.test.ts @@ -117,18 +117,21 @@ describe('BuildParameters', () => { }); test.each` - targetPlatform | expectedExtension | androidExportType - ${Platform.types.Android} | ${'.apk'} | ${'androidPackage'} - ${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'} - ${Platform.types.Android} | ${''} | ${'androidStudioProject'} - ${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'} - ${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'} + targetPlatform | expectedExtension | androidExportType | linux64RemoveExecutableExtension + ${Platform.types.Android} | ${'.apk'} | ${'androidPackage'} | ${false} + ${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'} | ${true} + ${Platform.types.Android} | ${''} | ${'androidStudioProject'} | ${false} + ${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'} | ${true} + ${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'} | ${false} + ${Platform.types.StandaloneLinux64} | ${'.x86_64'} | ${'n/a'} | ${false} + ${Platform.types.StandaloneLinux64} | ${''} | ${'n/a'} | ${true} `( - 'appends $expectedExtension for $targetPlatform with androidExportType $androidExportType', - async ({ targetPlatform, expectedExtension, androidExportType }) => { + 'appends $expectedExtension for $targetPlatform with linux64RemoveExecutableExtension=$linux64RemoveExecutableExtension', + async ({ targetPlatform, expectedExtension, androidExportType, linux64RemoveExecutableExtension }) => { vi.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform); vi.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform); vi.spyOn(Input, 'androidExportType', 'get').mockReturnValue(androidExportType); + vi.spyOn(Input, 'linux64RemoveExecutableExtension', 'get').mockReturnValue(linux64RemoveExecutableExtension); await expect(BuildParameters.create()).resolves.toEqual( expect.objectContaining({ buildFile: `${targetPlatform}${expectedExtension}` }), ); diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index e19d55f7..5b7fcfb7 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -73,6 +73,7 @@ class BuildParameters { Input.buildName, Input.targetPlatform, Input.androidExportType, + Input.linux64RemoveExecutableExtension, ); const editorVersion = UnityVersioning.determineUnityVersion( Input.projectPath, @@ -188,7 +189,12 @@ class BuildParameters { }; } - static parseBuildFile(filename: string, platform: string, androidExportType: string): string { + static parseBuildFile( + filename: string, + platform: string, + androidExportType: string, + linux64RemoveExecutableExtension: boolean, + ): string { if (Platform.isWindows(platform)) { return `${filename}.exe`; } @@ -208,6 +214,10 @@ class BuildParameters { } } + if (platform === Platform.types.StandaloneLinux64 && !linux64RemoveExecutableExtension) { + return `${filename}.x86_64`; + } + return filename; } diff --git a/src/model/input.test.ts b/src/model/input.test.ts index fc646d6e..dbd3f0cf 100644 --- a/src/model/input.test.ts +++ b/src/model/input.test.ts @@ -353,4 +353,22 @@ describe('Input', () => { expect(spy).toHaveBeenCalledTimes(1); }); }); + + describe('linux64RemoveExecutableExtension', () => { + it('returns the default value', () => { + expect(Input.linux64RemoveExecutableExtension).toStrictEqual(false); + }); + + it('returns true when string true is passed', () => { + const spy = vi.spyOn(core, 'getInput').mockReturnValue('true'); + expect(Input.linux64RemoveExecutableExtension).toStrictEqual(true); + expect(spy).toHaveBeenCalledTimes(1); + }); + + it('returns false when string false is passed', () => { + const spy = vi.spyOn(core, 'getInput').mockReturnValue('false'); + expect(Input.linux64RemoveExecutableExtension).toStrictEqual(false); + expect(spy).toHaveBeenCalledTimes(1); + }); + }); }); diff --git a/src/model/input.ts b/src/model/input.ts index 3194b0f0..0d564a71 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -284,6 +284,12 @@ class Input { return Input.getInput('skipActivation')?.toLowerCase() ?? 'false'; } + static get linux64RemoveExecutableExtension(): boolean { + const input = Input.getInput('linux64RemoveExecutableExtension') ?? 'false'; + + return input === 'true'; + } + public static ToEnvVarFormat(input: string) { if (input.toUpperCase() === input) { return input;