Add system to build Android Project. Update PR Template links. Fix missing types on functions. Cleanup mac-setup module installation
parent
5b5648adc4
commit
5484744bfc
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
<!-- please check all items and add your own -->
|
||||
|
||||
- [x] Read the contribution [guide](https://github.com/game-ci/unity-builder/blob/main/CONTRIBUTING.md) and accept the [code](https://github.com/game-ci/unity-builder/blob/main/CODE_OF_CONDUCT.md) of conduct
|
||||
- [x] Read the contribution [guide](https://github.com/game-ci/unity-builder/blob/main/CONTRIBUTING.md) and accept the
|
||||
[code](https://github.com/game-ci/unity-builder/blob/main/CODE_OF_CONDUCT.md) of conduct
|
||||
- [ ] Readme (updated or not needed)
|
||||
- [ ] Tests (added, updated or not needed)
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ inputs:
|
|||
required: false
|
||||
default: ''
|
||||
description: 'The android target API level.'
|
||||
exportAsGoogleAndroidProject:
|
||||
required: false
|
||||
default: 'false'
|
||||
description: 'To export Google Android Studio project.'
|
||||
sshAgent:
|
||||
required: false
|
||||
default: ''
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ namespace UnityBuilderAction.Input
|
|||
}
|
||||
PlayerSettings.Android.targetSdkVersion = targetSdkVersion;
|
||||
}
|
||||
if (options.TryGetValue("exportAsGoogleAndroidProject", out string exportAsGoogleAndroidProject) &&
|
||||
!string.IsNullOrEmpty(exportAsGoogleAndroidProject))
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = bool.Parse(exportAsGoogleAndroidProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
|
|||
class BuildParameters {
|
||||
static create() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidAppBundle);
|
||||
const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidAppBundle, input_1.default.exportAsGoogleAndroidProject);
|
||||
const editorVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
|
||||
const buildVersion = yield versioning_1.default.determineBuildVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
|
||||
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
|
||||
|
|
@ -270,6 +270,7 @@ class BuildParameters {
|
|||
androidKeyaliasPass: input_1.default.androidKeyaliasPass,
|
||||
androidTargetSdkVersion: input_1.default.androidTargetSdkVersion,
|
||||
androidSdkManagerParameters,
|
||||
exportAsGoogleAndroidProject: input_1.default.exportAsGoogleAndroidProject,
|
||||
customParameters: input_1.default.customParameters,
|
||||
sshAgent: input_1.default.sshAgent,
|
||||
gitPrivateToken: input_1.default.gitPrivateToken || (yield github_cli_1.GithubCliReader.GetGitHubAuthToken()),
|
||||
|
|
@ -312,11 +313,11 @@ class BuildParameters {
|
|||
};
|
||||
});
|
||||
}
|
||||
static parseBuildFile(filename, platform, androidAppBundle) {
|
||||
static parseBuildFile(filename, platform, androidAppBundle, exportAsGoogleAndroidProject) {
|
||||
if (platform_1.default.isWindows(platform)) {
|
||||
return `${filename}.exe`;
|
||||
}
|
||||
if (platform_1.default.isAndroid(platform)) {
|
||||
if (platform_1.default.isAndroid(platform) && exportAsGoogleAndroidProject !== 'true') {
|
||||
return androidAppBundle ? `${filename}.aab` : `${filename}.apk`;
|
||||
}
|
||||
return filename;
|
||||
|
|
@ -6635,6 +6636,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'ANDROID_KEYALIAS_PASS', value: parameters.androidKeyaliasPass },
|
||||
{ name: 'ANDROID_TARGET_SDK_VERSION', value: parameters.androidTargetSdkVersion },
|
||||
{ name: 'ANDROID_SDK_MANAGER_PARAMETERS', value: parameters.androidSdkManagerParameters },
|
||||
{ name: 'EXPORT_AS_GOOGLE_ANDROID_PROJECT', value: parameters.exportAsGoogleAndroidProject },
|
||||
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
|
||||
{ name: 'CHOWN_FILES_TO', value: parameters.chownFilesTo },
|
||||
{ name: 'GITHUB_REF', value: process.env.GITHUB_REF },
|
||||
|
|
@ -7222,6 +7224,9 @@ class Input {
|
|||
static get androidTargetSdkVersion() {
|
||||
return Input.getInput('androidTargetSdkVersion') || '';
|
||||
}
|
||||
static get exportAsGoogleAndroidProject() {
|
||||
return Input.getInput('exportAsGoogleAndroidProject') || 'false';
|
||||
}
|
||||
static get sshAgent() {
|
||||
return Input.getInput('sshAgent') || '';
|
||||
}
|
||||
|
|
@ -7535,6 +7540,29 @@ class SetupMac {
|
|||
return '';
|
||||
});
|
||||
}
|
||||
static getModuleParametersForTargetPlatform(targetPlatform) {
|
||||
let moduleArgument = '';
|
||||
switch (targetPlatform) {
|
||||
case 'iOS':
|
||||
moduleArgument += `--module ios `;
|
||||
break;
|
||||
case 'tvOS':
|
||||
moduleArgument += '--module tvos ';
|
||||
break;
|
||||
case 'StandaloneOSX':
|
||||
moduleArgument += `--module mac-il2cpp `;
|
||||
break;
|
||||
case 'Android':
|
||||
moduleArgument += `--module android `;
|
||||
break;
|
||||
case 'WebGL':
|
||||
moduleArgument += '--module webgl ';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported module for target platform: ${targetPlatform}.`);
|
||||
}
|
||||
return moduleArgument;
|
||||
}
|
||||
static installUnity(buildParameters, silent = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}`;
|
||||
|
|
@ -7547,29 +7575,12 @@ class SetupMac {
|
|||
}
|
||||
}
|
||||
const unityChangeset = yield unity_changeset_1.getUnityChangeset(buildParameters.editorVersion);
|
||||
let command = `${this.unityHubExecPath} -- --headless install \
|
||||
const moduleArgument = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);
|
||||
const command = `${this.unityHubExecPath} -- --headless install \
|
||||
--version ${buildParameters.editorVersion} \
|
||||
--changeset ${unityChangeset.changeset} `;
|
||||
switch (buildParameters.targetPlatform) {
|
||||
case 'iOS':
|
||||
command += `--module ios `;
|
||||
break;
|
||||
case 'tvOS':
|
||||
command += '--module tvos ';
|
||||
break;
|
||||
case 'StandaloneOSX':
|
||||
command += `--module mac-il2cpp `;
|
||||
break;
|
||||
case 'Android':
|
||||
command += `--module android `;
|
||||
break;
|
||||
case 'WebGL':
|
||||
command += '--module webgl ';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported module for target platform: ${buildParameters.targetPlatform}.`);
|
||||
}
|
||||
command += `--childModules`;
|
||||
--changeset ${unityChangeset.changeset} \
|
||||
${moduleArgument} \
|
||||
--childModules `;
|
||||
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
||||
// a false error
|
||||
const errorCode = yield exec_1.exec(command, undefined, { silent, ignoreReturnCode: true });
|
||||
|
|
@ -7604,6 +7615,7 @@ class SetupMac {
|
|||
process.env.ANDROID_KEYALIAS_PASS = buildParameters.androidKeyaliasPass;
|
||||
process.env.ANDROID_TARGET_SDK_VERSION = buildParameters.androidTargetSdkVersion;
|
||||
process.env.ANDROID_SDK_MANAGER_PARAMETERS = buildParameters.androidSdkManagerParameters;
|
||||
process.env.EXPORT_AS_GOOGLE_ANDROID_PROJECT = buildParameters.exportAsGoogleAndroidProject;
|
||||
process.env.CUSTOM_PARAMETERS = buildParameters.customParameters;
|
||||
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -147,6 +147,7 @@ echo ""
|
|||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||
-androidTargetSdkVersion "$ANDROID_TARGET_SDK_VERSION" \
|
||||
-exportAsGoogleAndroidProject "$EXPORT_AS_GOOGLE_ANDROID_PROJECT" \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ unity-editor \
|
|||
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
|
||||
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
|
||||
-androidTargetSdkVersion "$ANDROID_TARGET_SDK_VERSION" \
|
||||
-exportAsGoogleAndroidProject "$EXPORT_AS_GOOGLE_ANDROID_PROJECT" \
|
||||
$CUSTOM_PARAMETERS
|
||||
|
||||
# Catch exit code
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ $_, $customParametersArray = Invoke-Expression('Write-Output -- "" ' + $Env:CUST
|
|||
-androidKeyaliasName $Env:ANDROID_KEYALIAS_NAME `
|
||||
-androidKeyaliasPass $Env:ANDROID_KEYALIAS_PASS `
|
||||
-androidTargetSdkVersion $Env:ANDROID_TARGET_SDK_VERSION `
|
||||
-exportAsGoogleAndroidProject $Env:EXPORT_AS_GOOGLE_ANDROID_PROJECT `
|
||||
$customParametersArray `
|
||||
-logfile | Out-Host
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class BuildParameters {
|
|||
public androidKeyaliasPass!: string;
|
||||
public androidTargetSdkVersion!: string;
|
||||
public androidSdkManagerParameters!: string;
|
||||
public exportAsGoogleAndroidProject!: string;
|
||||
|
||||
public customParameters!: string;
|
||||
public sshAgent!: string;
|
||||
public cloudRunnerCluster!: string;
|
||||
|
|
@ -75,7 +77,12 @@ class BuildParameters {
|
|||
public unityHubVersionOnMac!: string;
|
||||
|
||||
static async create(): Promise<BuildParameters> {
|
||||
const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidAppBundle);
|
||||
const buildFile = this.parseBuildFile(
|
||||
Input.buildName,
|
||||
Input.targetPlatform,
|
||||
Input.androidAppBundle,
|
||||
Input.exportAsGoogleAndroidProject,
|
||||
);
|
||||
const editorVersion = UnityVersioning.determineUnityVersion(Input.projectPath, Input.unityVersion);
|
||||
const buildVersion = await Versioning.determineBuildVersion(Input.versioningStrategy, Input.specifiedVersion);
|
||||
const androidVersionCode = AndroidVersioning.determineVersionCode(buildVersion, Input.androidVersionCode);
|
||||
|
|
@ -120,6 +127,7 @@ class BuildParameters {
|
|||
androidKeyaliasPass: Input.androidKeyaliasPass,
|
||||
androidTargetSdkVersion: Input.androidTargetSdkVersion,
|
||||
androidSdkManagerParameters,
|
||||
exportAsGoogleAndroidProject: Input.exportAsGoogleAndroidProject,
|
||||
customParameters: Input.customParameters,
|
||||
sshAgent: Input.sshAgent,
|
||||
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
|
||||
|
|
@ -162,19 +170,24 @@ class BuildParameters {
|
|||
};
|
||||
}
|
||||
|
||||
static parseBuildFile(filename, platform, androidAppBundle) {
|
||||
static parseBuildFile(
|
||||
filename: string,
|
||||
platform: string,
|
||||
androidAppBundle: boolean,
|
||||
exportAsGoogleAndroidProject: string,
|
||||
) {
|
||||
if (Platform.isWindows(platform)) {
|
||||
return `${filename}.exe`;
|
||||
}
|
||||
|
||||
if (Platform.isAndroid(platform)) {
|
||||
if (Platform.isAndroid(platform) && exportAsGoogleAndroidProject !== 'true') {
|
||||
return androidAppBundle ? `${filename}.aab` : `${filename}.apk`;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
static getSerialFromLicenseFile(license) {
|
||||
static getSerialFromLicenseFile(license: string) {
|
||||
const startKey = `<DeveloperData Value="`;
|
||||
const endKey = `"/>`;
|
||||
const startIndex = license.indexOf(startKey) + startKey.length;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class ImageEnvironmentFactory {
|
|||
{ name: 'ANDROID_KEYALIAS_PASS', value: parameters.androidKeyaliasPass },
|
||||
{ name: 'ANDROID_TARGET_SDK_VERSION', value: parameters.androidTargetSdkVersion },
|
||||
{ name: 'ANDROID_SDK_MANAGER_PARAMETERS', value: parameters.androidSdkManagerParameters },
|
||||
{ name: 'EXPORT_AS_GOOGLE_ANDROID_PROJECT', value: parameters.exportAsGoogleAndroidProject },
|
||||
{ name: 'CUSTOM_PARAMETERS', value: parameters.customParameters },
|
||||
{ name: 'CHOWN_FILES_TO', value: parameters.chownFilesTo },
|
||||
{ name: 'GITHUB_REF', value: process.env.GITHUB_REF },
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ class Input {
|
|||
return Input.getInput('androidTargetSdkVersion') || '';
|
||||
}
|
||||
|
||||
static get exportAsGoogleAndroidProject() {
|
||||
return Input.getInput('exportAsGoogleAndroidProject') || 'false';
|
||||
}
|
||||
|
||||
static get sshAgent() {
|
||||
return Input.getInput('sshAgent') || '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,31 @@ class SetupMac {
|
|||
return '';
|
||||
}
|
||||
|
||||
private static getModuleParametersForTargetPlatform(targetPlatform: string): string {
|
||||
let moduleArgument = '';
|
||||
switch (targetPlatform) {
|
||||
case 'iOS':
|
||||
moduleArgument += `--module ios `;
|
||||
break;
|
||||
case 'tvOS':
|
||||
moduleArgument += '--module tvos ';
|
||||
break;
|
||||
case 'StandaloneOSX':
|
||||
moduleArgument += `--module mac-il2cpp `;
|
||||
break;
|
||||
case 'Android':
|
||||
moduleArgument += `--module android `;
|
||||
break;
|
||||
case 'WebGL':
|
||||
moduleArgument += '--module webgl ';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported module for target platform: ${targetPlatform}.`);
|
||||
}
|
||||
|
||||
return moduleArgument;
|
||||
}
|
||||
|
||||
private static async installUnity(buildParameters: BuildParameters, silent = false) {
|
||||
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}`;
|
||||
const key = `Cache-MacOS-UnityEditor-With-Module-${buildParameters.targetPlatform}@${buildParameters.editorVersion}`;
|
||||
|
|
@ -85,31 +110,13 @@ class SetupMac {
|
|||
}
|
||||
|
||||
const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
|
||||
let command = `${this.unityHubExecPath} -- --headless install \
|
||||
const moduleArgument = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform);
|
||||
|
||||
const command = `${this.unityHubExecPath} -- --headless install \
|
||||
--version ${buildParameters.editorVersion} \
|
||||
--changeset ${unityChangeset.changeset} `;
|
||||
|
||||
switch (buildParameters.targetPlatform) {
|
||||
case 'iOS':
|
||||
command += `--module ios `;
|
||||
break;
|
||||
case 'tvOS':
|
||||
command += '--module tvos ';
|
||||
break;
|
||||
case 'StandaloneOSX':
|
||||
command += `--module mac-il2cpp `;
|
||||
break;
|
||||
case 'Android':
|
||||
command += `--module android `;
|
||||
break;
|
||||
case 'WebGL':
|
||||
command += '--module webgl ';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported module for target platform: ${buildParameters.targetPlatform}.`);
|
||||
}
|
||||
|
||||
command += `--childModules`;
|
||||
--changeset ${unityChangeset.changeset} \
|
||||
${moduleArgument} \
|
||||
--childModules `;
|
||||
|
||||
// Ignoring return code because the log seems to overflow the internal buffer which triggers
|
||||
// a false error
|
||||
|
|
@ -145,6 +152,7 @@ class SetupMac {
|
|||
process.env.ANDROID_KEYALIAS_PASS = buildParameters.androidKeyaliasPass;
|
||||
process.env.ANDROID_TARGET_SDK_VERSION = buildParameters.androidTargetSdkVersion;
|
||||
process.env.ANDROID_SDK_MANAGER_PARAMETERS = buildParameters.androidSdkManagerParameters;
|
||||
process.env.EXPORT_AS_GOOGLE_ANDROID_PROJECT = buildParameters.exportAsGoogleAndroidProject;
|
||||
process.env.CUSTOM_PARAMETERS = buildParameters.customParameters;
|
||||
process.env.CHOWN_FILES_TO = buildParameters.chownFilesTo;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue