forked from leanflutter/flutter_distributor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_package_publisher_appstore.dart
53 lines (48 loc) · 1.47 KB
/
app_package_publisher_appstore.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'dart:io';
import 'package:app_package_publisher/app_package_publisher.dart';
import 'package:flutter_app_publisher/src/publishers/appstore/publish_appstore_config.dart';
import 'package:shell_executor/shell_executor.dart';
/// AppStore doc [https://help.apple.com/asc/appsaltool/]
class AppPackagePublisherAppStore extends AppPackagePublisher {
@override
String get name => 'appstore';
@override
List<String> get supportedPlatforms => ['ios', 'macos'];
@override
Future<PublishResult> publish(
FileSystemEntity fileSystemEntity, {
Map<String, String>? environment,
Map<String, dynamic>? publishArguments,
PublishProgressCallback? onPublishProgress,
}) async {
File file = fileSystemEntity as File;
// Get type
String type = file.path.endsWith('.ipa') ? 'ios' : 'osx';
// Get config
PublishAppStoreConfig publishConfig =
PublishAppStoreConfig.parse(environment, publishArguments);
// Publish to AppStore
ProcessResult processResult = await $(
'xcrun',
[
'altool',
'--upload-app',
'--file',
file.path,
'--type',
type,
// cmd list
...publishConfig.toAppStoreCliDistributeArgs()
],
);
if (processResult.exitCode == 0) {
return PublishResult(
url: 'https://appstoreconnect.apple.com/apps',
);
} else {
throw PublishError(
'${processResult.exitCode} - Upload of appstore failed',
);
}
}
}