sendBuildSummary method
Send build completion summary, then upload the APK when there is one.
Implementation
Future<void> sendBuildSummary({
required String client,
required String platform,
required String type,
required String version,
required bool success,
required Duration buildTime,
String? errorMessage,
File? artifactFile,
}) async {
_debugLog('=== BUILD SUMMARY ===');
_debugLog('Success: $success');
_debugLog('Type: $type');
_debugLog('Artifact file: ${artifactFile?.path ?? 'null'}');
final duration = '${buildTime.inMinutes}m ${buildTime.inSeconds % 60}s';
final fields = <String, String>{
'Client': client,
'Platform': platform,
'Type': type.toUpperCase(),
'Version': version,
'Build Time': duration,
'Status': success ? 'SUCCESS' : 'FAILED',
if (errorMessage != null) 'Error': errorMessage,
if (artifactFile != null) 'Artifact': path.basename(artifactFile.path),
};
final posted = await sendRichMessage(
title: success
? ':white_check_mark: Build Succeeded - $client'
: ':x: Build Failed - $client',
message: success
? 'The $platform ${type.toUpperCase()} build for "$client" completed in $duration.'
: 'The $platform build for "$client" failed after $duration.',
color: success ? 'good' : 'danger',
fields: fields,
);
if (!posted) {
Logger.warning('Failed to send build summary to Slack.');
}
final isApk = type.toLowerCase() == 'apk';
if (success && isApk && artifactFile != null && artifactFile.existsSync()) {
Logger.info('Uploading APK artifact to Slack...');
final uploadSuccess = await uploadFile(
file: artifactFile,
title: '📱 ${path.basename(artifactFile.path)}',
comment: 'Fresh build ready for testing! 🚀\n\n'
'• Client: $client\n'
'• Version: $version\n'
'• Platform: $platform\n'
'• Build time: $duration',
);
if (!uploadSuccess) {
Logger.warning('Failed to upload APK artifact to Slack.');
}
} else if (success && !isApk) {
Logger.info(
'Artifact upload skipped — only APKs are uploaded to Slack (build type is "$type").');
}
}