Skip to content

Commit a7c5b12

Browse files
authored
Add option to produce .aab file instead of .apk for Android builds (#270)
* Remove deprecation * Align UnityCMD input options with other tasks and remove deprecation * Revert extension version change until ready for release * Organize input variables into logical groups * Add keystore input options * Map and pass new inputs * Add missing changelog * Add option to build app bundle instead of APK * Introduce new configuration option to build using build profile * Update CHANGELOG * Do not store build profile as filePath input since we only need the path relative to project root * Update README * Add PR trigger * Update gitignore * Fix tests
1 parent 44b72bf commit a7c5b12

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

Tasks/UnityBuild/UnityBuildV3/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [3.2.5]
8+
## [3.3.0]
99

1010
### Added
1111

1212
- Add visionOS build target
1313
- Add configuration options to sign an Android build using a keystore
14+
- Add configuration option to build Android App Bundle (aab file) instead of APK
15+
- Introduce new configuration option to build using build profiles. This feature is only available for Unity 6 and above
1416

1517
### Changed
1618

Tasks/UnityBuild/UnityBuildV3/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dinomite-studios/unity-build-task",
3-
"version": "3.2.5",
3+
"version": "3.3.0",
44
"description": "An Azure Pipelines task to build Unity projects.",
55
"main": "unity-build.js",
66
"scripts": {
@@ -27,4 +27,4 @@
2727
"devDependencies": {
2828
"typescript": "^5.6.2"
2929
}
30-
}
30+
}

Tasks/UnityBuild/UnityBuildV3/task.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@
186186
"defaultValue": "",
187187
"helpMarkDown": "(Optional) Specify additional command line arguments, see the [documentation](https://docs.unity3d.com/Manual/CommandLineArguments.html) for more info."
188188
},
189+
{
190+
"name": "buildAppBundle",
191+
"type": "boolean",
192+
"label": "Build Android App Bundle (Google Play)",
193+
"groupName": "platform",
194+
"defaultValue": false,
195+
"required": false,
196+
"helpMarkDown": "Set to true to build an Android App Bundle (aab file) instead of an apk. The default value is false.",
197+
"visibleRule": "buildTarget == Android && buildScriptType == default"
198+
},
189199
{
190200
"name": "signAppBundle",
191201
"type": "boolean",

Tasks/UnityBuild/UnityBuildV3/unity-build.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const keystoreNameInputVariableName = 'keystoreName';
2929
const keystorePassInputVariableName = 'keystorePass';
3030
const keystoreAliasNameInputVariableName = 'keystoreAliasName';
3131
const keystoreAliasPassInputVariableName = 'keystoreAliasPass';
32+
const buildAppBundleInputVariableName = 'buildAppBundle';
33+
const buildFlowInputVariableName = 'buildFlow';
34+
const buildProfileInputVariableName = 'buildProfile';
3235

3336
// Output variables.
3437
const editorLogFilePathOutputVariableName = 'editorLogFilePath';
@@ -40,7 +43,6 @@ async function run() {
4043

4144
// Setup and read inputs.
4245
const outputFileName = tl.getInput(outputFileNameInputVariableName) ?? 'drop';
43-
const buildTarget = tl.getInput(buildTargetInputVariableName, true)!;
4446
const projectPath = tl.getPathInput(unityProjectPathInputVariableName) ?? '';
4547
const versionSelectionMode = tl.getInput(versionSelectionModeVariableName, true)!
4648
const outputPath = tl.getPathInput(outputPathInputVariableName) ?? '';
@@ -82,11 +84,15 @@ async function run() {
8284
tl.checkPath(outputPath, 'Build Output Directory');
8385

8486
// Execute Unity command line.
87+
const buildFlow = tl.getInput(buildFlowInputVariableName) ?? 'platform';
8588
const unityCmd = tl.tool(unityExecutablePath)
8689
.arg('-batchmode')
87-
.arg('-buildTarget').arg(buildTarget)
88-
.arg('-projectPath').arg(projectPath)
89-
.arg('-logfile').arg(logFilePath);
90+
.arg(buildFlow === 'platform' ? '-buildTarget' : '-activeBuildProfile')
91+
.arg(tl.getInput(buildFlow === 'platform' ? buildTargetInputVariableName : buildProfileInputVariableName, true)!)
92+
.arg('-projectPath')
93+
.arg(projectPath)
94+
.arg('-logfile')
95+
.arg(logFilePath);
9096

9197
const additionalArgs = tl.getInput(additionalCmdArgsInputVariableName) ?? '';
9298
if (additionalArgs !== '') {
@@ -115,6 +121,10 @@ async function run() {
115121
unityCmd.arg('-keystoreAliasPass').arg(keystoreAliasPass);
116122
}
117123
}
124+
125+
if (tl.getBoolInput(buildAppBundleInputVariableName)) {
126+
unityCmd.arg('-buildAppBundle');
127+
}
118128
} else if (buildScriptType === 'inline') {
119129
// Create a C# script file in a Editor folder at the root Assets directory level. Then write
120130
// the default or the user's script into it. Unity will then compile it on launch and make sure it's available.

0 commit comments

Comments
 (0)