diff --git a/tool/_build.dart b/tool/_build.dart index a0c7bffe..79a7e81d 100644 --- a/tool/_build.dart +++ b/tool/_build.dart @@ -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项目') diff --git a/tool/config.dart b/tool/config.dart new file mode 100644 index 00000000..59b0abf0 --- /dev/null +++ b/tool/config.dart @@ -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'; +} diff --git a/tool/grind.dart b/tool/grind.dart index 416dc5fa..c6fe3210 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -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 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; +} \ No newline at end of file