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 IosDeploymentStrategy',
'Selected lane: $lane',
];
// 1. Determine & validate artifact path
String? artifactPath = context.artifactPath;
if (artifactPath == null || artifactPath.isEmpty) {
steps.add('No explicit artifact provided. Discovering iOS artifact...');
artifactPath = await _artifactFinder.findArtifact(
projectPath: context.projectPath,
format: BuildFormat.ipa,
);
}
if (artifactPath == null || artifactPath.isEmpty) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
message: 'iOS deployment failed: No iOS build artifact (.ipa) found.',
executedSteps: steps,
errors: [
'No .ipa file found in ${context.projectPath}/build. Build IPA 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:
'iOS deployment failed: Specified artifact file does not exist.',
executedSteps: steps,
errors: ['File not found at path: $artifactPath'],
);
}
if (!artifactPath.endsWith('.ipa')) {
return DeploymentResult.failure(
platform: platform,
lane: lane,
artifactPath: artifactPath,
message: 'iOS deployment failed: Expected .ipa file extension.',
executedSteps: steps,
errors: [
'Expected .ipa file extension for iOS deployment: $artifactPath'
],
);
}
steps.add('Artifact validation passed (.ipa 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,
);
}