打包脚本自动修改命名

hmxc
张萌 3 years ago
parent 34e51ee797
commit b111df6e2f

@ -12,6 +12,13 @@ buildApk() async {
'BUILD_TYPE=PRODUCT',
],
);
String date = DateUtil.formatDate(DateTime.now(), format: 'yy_MM_dd_HH_mm');
String version = await getVersion();
await runAsync('mv', arguments: [
Config.buildPath,
'${Config.buildDir}/${Config.packageName}_${version}_release_$date.apk'
]);
}
@Task('打包Android项目')
@ -26,6 +33,12 @@ buildApkDev() async {
'BUILD_TYPE=Dev',
],
);
String date = DateUtil.formatDate(DateTime.now(), format: 'yy_MM_dd_HH_mm');
String version = await getVersion();
await runAsync('mv', arguments: [
Config.buildPath,
'${Config.buildDir}/${Config.packageName}_${version}_beta_$date.apk'
]);
}
@Task('打包iOS项目')

@ -0,0 +1,14 @@
class Config {
///
static const String homeDir = '/users/zhangmeng';
///
static const String packageName = 'aku_community';
///
static String get buildPath =>
'./build/app/outputs/flutter-apk/app-release.apk';
///
static String get buildDir => './build/app/outputs/flutter-apk';
}

@ -1,10 +1,11 @@
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:grinder/grinder.dart';
import 'package:path/path.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
import 'config.dart';
import 'version_tool.dart';
part '_build.dart';
@ -26,3 +27,13 @@ void addVersion() async {
String result = yamlContent.replaceFirst(version, resultVersion.toString());
await File(yamlPath).writeAsString(result);
}
@Task()
Future<String> getVersion() async {
String projectPath = Directory('.').absolute.path;
String yamlPath = join(projectPath, 'pubspec.yaml');
String yamlContent = await File(yamlPath).readAsString();
dynamic content = loadYaml(yamlContent);
String version = content['version'];
return version;
}
Loading…
Cancel
Save