Skip to content

Commit

Permalink
feat(shorebird_cli): shorebird release android support for `--split…
Browse files Browse the repository at this point in the history
…-per-abi` (#1010)
  • Loading branch information
felangel authored Aug 3, 2023
1 parent 8f4ae02 commit a94a447
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class ReleaseAndroidCommand extends ShorebirdCommand
'apk': 'Android Package Kit',
},
)
..addFlag(
'split-per-abi',
help: 'Whether to split the APKs per ABIs. '
'To learn more, see: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',
negatable: false,
)
..addFlag(
'force',
abbr: 'f',
Expand Down Expand Up @@ -79,7 +85,13 @@ make smaller updates to your app.
final buildProgress = logger.progress('Building release');
try {
await buildAppBundle(flavor: flavor, target: target);
if (generateApk) await buildApk(flavor: flavor, target: target);
if (generateApk) {
await buildApk(
flavor: flavor,
target: target,
splitPerAbi: results['split-per-abi'] == true,
);
}
buildProgress.complete();
} on ProcessException catch (error) {
buildProgress.fail('Failed to build: ${error.message}');
Expand Down
7 changes: 6 additions & 1 deletion packages/shorebird_cli/lib/src/shorebird_build_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,19 @@ mixin ShorebirdBuildMixin on ShorebirdCommand {
}
}

Future<void> buildApk({String? flavor, String? target}) async {
Future<void> buildApk({
String? flavor,
String? target,
bool? splitPerAbi,
}) async {
const executable = 'flutter';
final arguments = [
'build',
'apk',
'--release',
if (flavor != null) '--flavor=$flavor',
if (target != null) '--target=$target',
if (splitPerAbi != null) '--split-per-abi',
...results.rest,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,45 @@ void main() {
expect(exitCode, ExitCode.success.code);
});

test('succeeds when release is successful (with apk + split-per-abi)',
() async {
when(() => argResults['artifact']).thenReturn('apk');
when(() => argResults['split-per-abi']).thenReturn(true);
final exitCode = await runWithOverrides(command.run);
verify(() => logger.success('\n✅ Published Release!')).called(1);
verify(
() => codePushClientWrapper.createAndroidReleaseArtifacts(
appId: appId,
releaseId: release.id,
platform: releasePlatform,
aabPath: any(named: 'aabPath'),
architectures: any(named: 'architectures'),
),
).called(1);
verify(
() => codePushClientWrapper.updateReleaseStatus(
appId: appId,
releaseId: release.id,
platform: releasePlatform,
status: ReleaseStatus.active,
),
).called(1);
final buildApkArguments = [
'build',
'apk',
'--release',
'--split-per-abi'
];
verify(
() => shorebirdProcess.run(
'flutter',
buildApkArguments,
runInShell: true,
),
).called(1);
expect(exitCode, ExitCode.success.code);
});

test(
'succeeds when release is successful '
'with flavors and target', () async {
Expand Down

0 comments on commit a94a447

Please sign in to comment.