executeRelease method
Executes shorebird release <platform>.
Implementation
Future<ShorebirdCommandResult> executeRelease({
required String projectPath,
required BuildPlatform platform,
required bool dryRun,
String? versionName,
int? buildNumber,
List<String> extraArgs = const [],
}) async {
final args = buildReleaseArgs(
platform: platform,
versionName: versionName,
buildNumber: buildNumber,
extraArgs: extraArgs,
);
final commandString = 'shorebird ${args.join(' ')}';
if (dryRun) {
return ShorebirdCommandResult.success(
commandString: commandString,
executedSteps: [
'[DRY-RUN] Verified Shorebird CLI installation.',
'[DRY-RUN] Command preview: $commandString',
],
);
}
final steps = <String>['Invoking: $commandString'];
try {
final result = await _runner.run(
'shorebird',
args,
workingDirectory: projectPath,
);
if (result.exitCode != 0) {
final errStr = result.stderr.toString().trim();
final outStr = result.stdout.toString().trim();
final combined = errStr.isNotEmpty ? errStr : outStr;
return ShorebirdCommandResult.failure(
commandString: commandString,
exitCode: result.exitCode,
stdout: outStr,
stderr: errStr,
executedSteps: steps,
errors: [
'Shorebird release failed with exit code ${result.exitCode}.',
if (combined.isNotEmpty) combined,
],
);
}
steps.add('Shorebird release completed successfully.');
return ShorebirdCommandResult.success(
commandString: commandString,
stdout: result.stdout.toString(),
stderr: result.stderr.toString(),
executedSteps: steps,
);
} catch (e) {
return ShorebirdCommandResult.failure(
commandString: commandString,
executedSteps: steps,
errors: ['Failed to execute Shorebird process: $e'],
);
}
}