mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
build script will update project.pbxproj versions.
This commit is contained in:
20
make.dart
20
make.dart
@@ -7,9 +7,12 @@ import 'dart:io';
|
|||||||
const appName = 'ServerBox';
|
const appName = 'ServerBox';
|
||||||
const buildDataFilePath = 'lib/data/res/build_data.dart';
|
const buildDataFilePath = 'lib/data/res/build_data.dart';
|
||||||
const xcarchivePath = 'build/ios/archive/Runner.xcarchive';
|
const xcarchivePath = 'build/ios/archive/Runner.xcarchive';
|
||||||
|
var regiOSProjectVer = RegExp(r'CURRENT_PROJECT_VERSION = .+;');
|
||||||
|
var regiOSMarketVer = RegExp(r'MARKETING_VERSION = .+');
|
||||||
const skslFileSuffix = '.sksl.json';
|
const skslFileSuffix = '.sksl.json';
|
||||||
|
|
||||||
|
int? build;
|
||||||
|
|
||||||
Future<int> getGitCommitCount() async {
|
Future<int> getGitCommitCount() async {
|
||||||
final result = await Process.run('git', ['log', '--oneline']);
|
final result = await Process.run('git', ['log', '--oneline']);
|
||||||
return (result.stdout as String)
|
return (result.stdout as String)
|
||||||
@@ -50,7 +53,7 @@ Future<String> getFlutterVersion() async {
|
|||||||
Future<Map<String, dynamic>> getBuildData() async {
|
Future<Map<String, dynamic>> getBuildData() async {
|
||||||
final data = {
|
final data = {
|
||||||
'name': appName,
|
'name': appName,
|
||||||
'build': await getGitCommitCount(),
|
'build': build,
|
||||||
'engine': await getFlutterVersion(),
|
'engine': await getFlutterVersion(),
|
||||||
'buildAt': DateTime.now().toString(),
|
'buildAt': DateTime.now().toString(),
|
||||||
'modifications': await getGitModificationCount(),
|
'modifications': await getGitModificationCount(),
|
||||||
@@ -85,8 +88,6 @@ void flutterRun(String? mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> flutterBuild(String source, String target, bool isAndroid) async {
|
Future<void> flutterBuild(String source, String target, bool isAndroid) async {
|
||||||
final build = await getGitCommitCount();
|
|
||||||
|
|
||||||
final args = [
|
final args = [
|
||||||
'build',
|
'build',
|
||||||
isAndroid ? 'apk' : 'ipa',
|
isAndroid ? 'apk' : 'ipa',
|
||||||
@@ -122,6 +123,7 @@ Future<void> flutterBuild(String source, String target, bool isAndroid) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> flutterBuildIOS() async {
|
Future<void> flutterBuildIOS() async {
|
||||||
|
await changeiOSVersion();
|
||||||
await flutterBuild(
|
await flutterBuild(
|
||||||
xcarchivePath, './release/${appName}_build.xcarchive', false);
|
xcarchivePath, './release/${appName}_build.xcarchive', false);
|
||||||
}
|
}
|
||||||
@@ -131,6 +133,15 @@ Future<void> flutterBuildAndroid() async {
|
|||||||
'./release/${appName}_build_Arm64.apk', true);
|
'./release/${appName}_build_Arm64.apk', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> changeiOSVersion() async {
|
||||||
|
final file = File('ios/Runner.xcodeproj/project.pbxproj');
|
||||||
|
final contents = await file.readAsString();
|
||||||
|
final newContents = contents
|
||||||
|
.replaceAll(regiOSMarketVer, 'MARKETING_VERSION = 1.0.$build;')
|
||||||
|
.replaceAll(regiOSProjectVer, 'CURRENT_PROJECT_VERSION = $build;');
|
||||||
|
await file.writeAsString(newContents);
|
||||||
|
}
|
||||||
|
|
||||||
void main(List<String> args) async {
|
void main(List<String> args) async {
|
||||||
if (args.isEmpty) {
|
if (args.isEmpty) {
|
||||||
print('No action. Exit.');
|
print('No action. Exit.');
|
||||||
@@ -145,6 +156,7 @@ void main(List<String> args) async {
|
|||||||
case 'build':
|
case 'build':
|
||||||
final stopwatch = Stopwatch()..start();
|
final stopwatch = Stopwatch()..start();
|
||||||
final buildFunc = [flutterBuildIOS, flutterBuildAndroid];
|
final buildFunc = [flutterBuildIOS, flutterBuildAndroid];
|
||||||
|
build = await getGitCommitCount();
|
||||||
await updateBuildData();
|
await updateBuildData();
|
||||||
dartFormat();
|
dartFormat();
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user