update
This commit is contained in:
parent
53fd31f2ae
commit
9bd79312a7
1 changed files with 51 additions and 32 deletions
|
|
@ -33,7 +33,10 @@ class BuildiOS extends Command {
|
|||
await getMainXcodeprojPath(data.xcworkspaceFilePath!);
|
||||
|
||||
/************ Auto find build number ************/
|
||||
var autoBuildNumber = (data.autoBuildNumber ?? false) ? !((version != null && version.isNotEmpty) || (buildNumber != null && buildNumber.isNotEmpty)) : false;
|
||||
var autoBuildNumber = (data.autoBuildNumber ?? false)
|
||||
? !((version != null && version.isNotEmpty) ||
|
||||
(buildNumber != null && buildNumber.isNotEmpty))
|
||||
: false;
|
||||
if (autoBuildNumber) {
|
||||
var appID = await getAppIdentifier(
|
||||
data.workspace, xcodeproj, data.scheme, data.setAppID);
|
||||
|
|
@ -41,7 +44,7 @@ class BuildiOS extends Command {
|
|||
throw Exception('Can not find App Identifier.');
|
||||
}
|
||||
var teamID = data.teamID;
|
||||
if(teamID == null) {
|
||||
if (teamID == null) {
|
||||
throw Exception('Can not find Apple Store Team ID');
|
||||
}
|
||||
if (data.apiKeyPath == null) {
|
||||
|
|
@ -49,7 +52,8 @@ class BuildiOS extends Command {
|
|||
'If autoVersionNumber = true then must set apiKeyPath.');
|
||||
}
|
||||
var apiKeyPath = data.apiKeyPath!;
|
||||
var fastFile = await initializeFastlane(data.workspace!, apiKeyPath, appID);
|
||||
var fastFile =
|
||||
await initializeFastlane(data.workspace!, apiKeyPath, appID);
|
||||
var fastlaneContent = fastFile.readAsStringSync();
|
||||
|
||||
//Find PREPARE_FOR_SUBMISSION state Version
|
||||
|
|
@ -59,7 +63,7 @@ class BuildiOS extends Command {
|
|||
shell.write(' && fastlane appstore_versions');
|
||||
var process = await ProcessExecutor.run(shell);
|
||||
var arr = process.stdout.toString().split('\n');
|
||||
const result = '[RESULT]: ';
|
||||
var result = '[RESULT]: ';
|
||||
for (var item in arr) {
|
||||
if (item.contains(result)) {
|
||||
var jsonArr =
|
||||
|
|
@ -87,12 +91,15 @@ class BuildiOS extends Command {
|
|||
fastFile.writeAsStringSync(fastlaneContent, flush: true);
|
||||
shell = StringBuffer();
|
||||
shell.write('cd ${data.workspace}/fastlane');
|
||||
shell.write(' && fastlane run latest_testflight_build_number app_identifier:$appID version:$version platform:ios api_key_path:"$apiKeyPath" team_id:"$teamID"');
|
||||
shell.write(
|
||||
' && fastlane run latest_testflight_build_number app_identifier:$appID version:$version platform:ios api_key_path:"$apiKeyPath" team_id:"$teamID"');
|
||||
process = await ProcessExecutor.run(shell);
|
||||
arr = process.stdout.toString().split('\n');
|
||||
result = 'RESULT: ';
|
||||
for (var item in arr) {
|
||||
if (item.contains(result)) {
|
||||
targetBuildNumber = item.substring(item.indexOf(result) + result.length).trim();
|
||||
targetBuildNumber =
|
||||
item.substring(item.indexOf(result) + result.length).trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -111,7 +118,8 @@ class BuildiOS extends Command {
|
|||
'${data.workspace}/$xcodeproj/project.pbxproj', version);
|
||||
} else {
|
||||
target = target ?? await getTargetXcodeproj(data.workspace!, xcodeproj!);
|
||||
version = await getSettingXcodeproj(data.workspace!, xcodeproj!, target!, 'MARKETING_VERSION');
|
||||
version = await getSettingXcodeproj(
|
||||
data.workspace!, xcodeproj!, target!, 'MARKETING_VERSION');
|
||||
}
|
||||
//buildNumber가 있을경우 세팅, 없을경우 기존 버전값을 메모리에 가지고 있음
|
||||
if (buildNumber != null && buildNumber.isNotEmpty) {
|
||||
|
|
@ -119,12 +127,18 @@ class BuildiOS extends Command {
|
|||
'${data.workspace}/$xcodeproj/project.pbxproj', buildNumber);
|
||||
} else {
|
||||
target = target ?? await getTargetXcodeproj(data.workspace!, xcodeproj!);
|
||||
buildNumber = await getSettingXcodeproj(data.workspace!, xcodeproj!, target!, 'CURRENT_PROJECT_VERSION');
|
||||
buildNumber = await getSettingXcodeproj(
|
||||
data.workspace!, xcodeproj!, target!, 'CURRENT_PROJECT_VERSION');
|
||||
}
|
||||
|
||||
var setVersion = data.setVersion != null && data.setVersion!.isNotEmpty ? data.setVersion! : '<@property.version>';
|
||||
var setVersion = data.setVersion != null && data.setVersion!.isNotEmpty
|
||||
? data.setVersion!
|
||||
: '<@property.version>';
|
||||
setProperty(setVersion, version);
|
||||
var setBuildNumber = data.setBuildNumber != null && data.setBuildNumber!.isNotEmpty ? data.setBuildNumber! : '<@property.buildNumber>';
|
||||
var setBuildNumber =
|
||||
data.setBuildNumber != null && data.setBuildNumber!.isNotEmpty
|
||||
? data.setBuildNumber!
|
||||
: '<@property.buildNumber>';
|
||||
setProperty(setBuildNumber, buildNumber);
|
||||
|
||||
var os = 'iOS';
|
||||
|
|
@ -198,25 +212,26 @@ class BuildiOS extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
static Future<File> initializeFastlane(String workspace, String apiKeyPath, String appID) async {
|
||||
static Future<File> initializeFastlane(
|
||||
String workspace, String apiKeyPath, String appID) async {
|
||||
var json = jsonDecode(File(apiKeyPath).readAsStringSync());
|
||||
var fastlaneContent = fastlaneTemplete;
|
||||
fastlaneContent = fastlaneContent
|
||||
.replaceFirst('[APP_IDENTIFIER]', appID)
|
||||
.replaceFirst('[API_KEY_ID]', json['key_id'])
|
||||
.replaceFirst('[API_ISSUER_ID]', json['issuer_id'])
|
||||
.replaceFirst('[AUTH_KEY_CONTENT]',
|
||||
json['key'].toString().replaceAll('\n', '\\n'));
|
||||
var fastlaneContent = fastlaneTemplete;
|
||||
fastlaneContent = fastlaneContent
|
||||
.replaceFirst('[APP_IDENTIFIER]', appID)
|
||||
.replaceFirst('[API_KEY_ID]', json['key_id'])
|
||||
.replaceFirst('[API_ISSUER_ID]', json['issuer_id'])
|
||||
.replaceFirst('[AUTH_KEY_CONTENT]',
|
||||
json['key'].toString().replaceAll('\n', '\\n'));
|
||||
|
||||
var shell = StringBuffer();
|
||||
shell.write('cd $workspace');
|
||||
shell.write(' && rm -rf "$workspace/fastlane"');
|
||||
shell.write(' && yes | fastlane init');
|
||||
await ProcessExecutor.run(shell);
|
||||
var shell = StringBuffer();
|
||||
shell.write('cd $workspace');
|
||||
shell.write(' && rm -rf "$workspace/fastlane"');
|
||||
shell.write(' && yes | fastlane init');
|
||||
await ProcessExecutor.run(shell);
|
||||
|
||||
var fastFile = File('$workspace/fastlane/Fastfile');
|
||||
fastFile.writeAsStringSync(fastlaneContent, flush: true);
|
||||
return dataFutrue(fastFile);
|
||||
var fastFile = File('$workspace/fastlane/Fastfile');
|
||||
fastFile.writeAsStringSync(fastlaneContent, flush: true);
|
||||
return dataFutrue(fastFile);
|
||||
}
|
||||
|
||||
Future<String?> getAppIdentifier(String? workspace, String? xcodeproj,
|
||||
|
|
@ -329,16 +344,18 @@ class BuildiOS extends Command {
|
|||
await file.writeAsString(updatedLines.join('\n'));
|
||||
}
|
||||
|
||||
Future<String?> getSettingXcodeproj(String workspace, String xcodeproj, String target, String marker) async {
|
||||
Future<String?> getSettingXcodeproj(
|
||||
String workspace, String xcodeproj, String target, String marker) async {
|
||||
String? version;
|
||||
var shell = StringBuffer();
|
||||
shell.write('cd $workspace');
|
||||
shell.write(' && xcodebuild -project $xcodeproj -target $target -showBuildSettings | grep $marker');
|
||||
shell.write(
|
||||
' && xcodebuild -project $xcodeproj -target $target -showBuildSettings | grep $marker');
|
||||
|
||||
var mark = '$marker = ';
|
||||
var process = await ProcessExecutor.run(shell);
|
||||
var arr = process.stdout.toString().split('\n');
|
||||
for(var item in arr) {
|
||||
for (var item in arr) {
|
||||
if (item.contains(mark)) {
|
||||
version = item.replaceAll(mark, '').trim();
|
||||
break;
|
||||
|
|
@ -347,15 +364,17 @@ class BuildiOS extends Command {
|
|||
return dataFutrue(version);
|
||||
}
|
||||
|
||||
Future<String?> getTargetXcodeproj(String workspace, String xcoodeproj) async {
|
||||
Future<String?> getTargetXcodeproj(
|
||||
String workspace, String xcoodeproj) async {
|
||||
String? target;
|
||||
var shell = StringBuffer();
|
||||
shell.write('cd $workspace');
|
||||
shell.write(" && xcodebuild -project $xcoodeproj -list | awk '/Targets:/ {getline; print; exit}'");
|
||||
shell.write(
|
||||
" && xcodebuild -project $xcoodeproj -list | awk '/Targets:/ {getline; print; exit}'");
|
||||
|
||||
var process = await ProcessExecutor.run(shell);
|
||||
var arr = process.stdout.toString().split('\n');
|
||||
for(var item in arr) {
|
||||
for (var item in arr) {
|
||||
item = item.trim();
|
||||
if (item.isNotEmpty) {
|
||||
target = item.trim();
|
||||
|
|
|
|||
Loading…
Reference in a new issue