Add parameter `linux64FileExtension`

Allows the end-user to restore the default unity behavior of
using the file extension `.x86_64`, instead of no file extension.

Preserves the current behavior, to avoid surprise breakage.
pull/726/head
Kitlith 2025-08-19 16:37:15 -07:00
parent c6c8236152
commit 893ac807c0
6 changed files with 53 additions and 13 deletions

10
dist/index.js generated vendored
View File

@ -252,7 +252,7 @@ class BuildParameters {
return buildParameters.maxRetainedWorkspaces > 0 && cloud_runner_1.default.lockedWorkspace !== ``; return buildParameters.maxRetainedWorkspaces > 0 && cloud_runner_1.default.lockedWorkspace !== ``;
} }
static async create() { static async create() {
const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidExportType); const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidExportType, input_1.default.linux64FileExtension);
const editorVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion); const editorVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
const buildVersion = await versioning_1.default.determineBuildVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion); const buildVersion = await versioning_1.default.determineBuildVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode); const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
@ -366,7 +366,7 @@ class BuildParameters {
dockerWorkspacePath: input_1.default.dockerWorkspacePath, dockerWorkspacePath: input_1.default.dockerWorkspacePath,
}; };
} }
static parseBuildFile(filename, platform, androidExportType) { static parseBuildFile(filename, platform, androidExportType, linux64FileExtension) {
if (platform_1.default.isWindows(platform)) { if (platform_1.default.isWindows(platform)) {
return `${filename}.exe`; return `${filename}.exe`;
} }
@ -382,6 +382,9 @@ class BuildParameters {
throw new Error(`Unknown Android Export Type: ${androidExportType}. Must be one of androidPackage for apk, androidAppBundle for aab, androidStudioProject for android project`); throw new Error(`Unknown Android Export Type: ${androidExportType}. Must be one of androidPackage for apk, androidAppBundle for aab, androidStudioProject for android project`);
} }
} }
if (platform === platform_1.default.types.StandaloneLinux64) {
return `${filename}${linux64FileExtension}`;
}
return filename; return filename;
} }
static getSerialFromLicenseFile(license) { static getSerialFromLicenseFile(license) {
@ -7118,6 +7121,9 @@ class Input {
static get skipActivation() { static get skipActivation() {
return Input.getInput('skipActivation')?.toLowerCase() ?? 'false'; return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
} }
static get linux64FileExtension() {
return Input.getInput('linux64FileExtension') ?? '';
}
static ToEnvVarFormat(input) { static ToEnvVarFormat(input) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -104,18 +104,21 @@ describe('BuildParameters', () => {
}); });
test.each` test.each`
targetPlatform | expectedExtension | androidExportType targetPlatform | expectedExtension | androidExportType | linux64FileExtension
${Platform.types.Android} | ${'.apk'} | ${'androidPackage'} ${Platform.types.Android} | ${'.apk'} | ${'androidPackage'} | ${'n/a'}
${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'} ${Platform.types.Android} | ${'.aab'} | ${'androidAppBundle'} | ${'n/a'}
${Platform.types.Android} | ${''} | ${'androidStudioProject'} ${Platform.types.Android} | ${''} | ${'androidStudioProject'} | ${'n/a'}
${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'} ${Platform.types.StandaloneWindows} | ${'.exe'} | ${'n/a'} | ${'n/a'}
${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'} ${Platform.types.StandaloneWindows64} | ${'.exe'} | ${'n/a'} | ${'n/a'}
${Platform.types.StandaloneLinux64} | ${''} | ${'n/a'} | ${''}
${Platform.types.StandaloneLinux64} | ${'.x86_64'} | ${'n/a'} | ${'.x86_64'}
`( `(
'appends $expectedExtension for $targetPlatform with androidExportType $androidExportType', 'appends $expectedExtension for $targetPlatform with androidExportType $androidExportType and linux64FileExtension $linux64FileExtension',
async ({ targetPlatform, expectedExtension, androidExportType }) => { async ({ targetPlatform, expectedExtension, androidExportType, linux64FileExtension }) => {
jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform); jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(targetPlatform);
jest.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform); jest.spyOn(Input, 'buildName', 'get').mockReturnValue(targetPlatform);
jest.spyOn(Input, 'androidExportType', 'get').mockReturnValue(androidExportType); jest.spyOn(Input, 'androidExportType', 'get').mockReturnValue(androidExportType);
jest.spyOn(Input, 'linux64FileExtension', 'get').mockReturnValue(linux64FileExtension);
await expect(BuildParameters.create()).resolves.toEqual( await expect(BuildParameters.create()).resolves.toEqual(
expect.objectContaining({ buildFile: `${targetPlatform}${expectedExtension}` }), expect.objectContaining({ buildFile: `${targetPlatform}${expectedExtension}` }),
); );

View File

@ -101,7 +101,12 @@ class BuildParameters {
} }
static async create(): Promise<BuildParameters> { static async create(): Promise<BuildParameters> {
const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidExportType); const buildFile = this.parseBuildFile(
Input.buildName,
Input.targetPlatform,
Input.androidExportType,
Input.linux64FileExtension,
);
const editorVersion = UnityVersioning.determineUnityVersion(Input.projectPath, Input.unityVersion); const editorVersion = UnityVersioning.determineUnityVersion(Input.projectPath, Input.unityVersion);
const buildVersion = await Versioning.determineBuildVersion(Input.versioningStrategy, Input.specifiedVersion); const buildVersion = await Versioning.determineBuildVersion(Input.versioningStrategy, Input.specifiedVersion);
const androidVersionCode = AndroidVersioning.determineVersionCode(buildVersion, Input.androidVersionCode); const androidVersionCode = AndroidVersioning.determineVersionCode(buildVersion, Input.androidVersionCode);
@ -223,7 +228,12 @@ class BuildParameters {
}; };
} }
static parseBuildFile(filename: string, platform: string, androidExportType: string): string { static parseBuildFile(
filename: string,
platform: string,
androidExportType: string,
linux64FileExtension: string,
): string {
if (Platform.isWindows(platform)) { if (Platform.isWindows(platform)) {
return `${filename}.exe`; return `${filename}.exe`;
} }
@ -243,6 +253,10 @@ class BuildParameters {
} }
} }
if (platform === Platform.types.StandaloneLinux64) {
return `${filename}${linux64FileExtension}`;
}
return filename; return filename;
} }

View File

@ -334,4 +334,17 @@ describe('Input', () => {
expect(spy).toHaveBeenCalledTimes(1); expect(spy).toHaveBeenCalledTimes(1);
}); });
}); });
describe('linux64FileExtension', () => {
it('returns the default value', () => {
expect(Input.linux64FileExtension).toStrictEqual('');
});
it('takes input from the users workflow', () => {
const mockValue = '.x86_64';
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
expect(Input.linux64FileExtension).toStrictEqual(mockValue);
expect(spy).toHaveBeenCalledTimes(1);
});
});
}); });

View File

@ -282,6 +282,10 @@ class Input {
return Input.getInput('skipActivation')?.toLowerCase() ?? 'false'; return Input.getInput('skipActivation')?.toLowerCase() ?? 'false';
} }
static get linux64FileExtension(): string {
return Input.getInput('linux64FileExtension') ?? '';
}
public static ToEnvVarFormat(input: string) { public static ToEnvVarFormat(input: string) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;