deploy method
Execute deployment using the given context.
Implementation
@override
Future<DeploymentResult> deploy(DeploymentContext context) async {
final lane = context.lane?.isNotEmpty == true ? context.lane! : defaultLane;
final steps = <String>[
'Initialized AndroidDeploymentStrategy',
'Selected lane: $lane',
];
// 1. Determine & validate artifact path
String? artifactPath = context.artifactPath;
if (artifactPath == null || artifactPath.isEmpty) {
steps.add(
'No explicit artifact provided. Discovering Android artifact...');
artifactPath = await _artifactFinder.findArtifact(
projectPath: context.projectPath,
format: BuildFormat.appbundle,
);
}
if (artifactPath == null || artifactPath.isEmpty) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
message:
'Android deployment failed: No Android build artifact (.aab) found.',
executedSteps: steps,
errors: [
'No .aab file found in ${context.projectPath}/build. Build app bundle first or pass --artifact <path>.',
],
);
}
steps.add('Found artifact: $artifactPath');
final artifactFile = File(artifactPath);
if (!await artifactFile.exists()) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
artifactPath: artifactPath,
message:
'Android deployment failed: Specified artifact file does not exist.',
executedSteps: steps,
errors: ['File not found at path: $artifactPath'],
);
}
if (artifactPath.endsWith('.apk')) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
artifactPath: artifactPath,
message: 'Android deployment failed: Invalid artifact format.',
executedSteps: steps,
errors: [
'Android store deployment requires an App Bundle (.aab). '
'APK files are not accepted for Google Play release.',
],
);
}
if (!artifactPath.endsWith('.aab')) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
artifactPath: artifactPath,
message: 'Android deployment failed: Expected .aab file extension.',
executedSteps: steps,
errors: [
'Invalid file extension for Android deployment: $artifactPath'
],
);
}
steps.add('Artifact validation passed (.aab format verified).');
// 2. Execute via Fastlane
final result = await _fastlaneRunner.executeLane(
projectPath: context.projectPath,
platform: platform,
lane: lane,
artifactPath: artifactPath,
dryRun: context.dryRun,
environment: context.environment,
);
return DeploymentResult(
success: result.success,
platform: platform,
lane: lane,
artifactPath: artifactPath,
message: result.message,
executedSteps: [...steps, ...result.executedSteps],
errors: result.errors,
warnings: result.warnings,
commandString: result.commandString,
metadata: result.metadata,
);
}