Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shorebird_cli): shorebird release android support for --split-per-abi #1010

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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