mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: github actions
This commit is contained in:
68
.github/workflows/release.yml
vendored
Normal file
68
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Flutter Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
releaseAL:
|
||||
name: Release android and linux
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Install Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
- name: Build
|
||||
run: dart run fl_build -p android,linux
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
build/app/outputs/flutter-apk/${{ env.APP_NAME }}_arm64.apk
|
||||
build/app/outputs/flutter-apk/${{ env.APP_NAME }}_arm.apk
|
||||
build/app/outputs/flutter-apk/${{ env.APP_NAME }}_amd64.apk
|
||||
${{ env.APP_NAME }}_amd64.AppImage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# releaseWin:
|
||||
# name: Release windows
|
||||
# runs-on: windows-latest
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# - name: Install Flutter
|
||||
# uses: subosito/flutter-action@v2
|
||||
# - name: Build
|
||||
# run: dart run fl_build -p windows
|
||||
# - name: Create Release
|
||||
# uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# files: |
|
||||
# ${{ env.APP_NAME }}_amd64_windows.zip
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# releaseApple:
|
||||
# name: Release ios and macos
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# - name: Install Flutter
|
||||
# uses: subosito/flutter-action@v2
|
||||
# - name: Build
|
||||
# run: dart run fl_build -p ios,mac
|
||||
# - name: Create Release
|
||||
# uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# files: |
|
||||
# ${{ env.APP_NAME }}_universal_macos.zip
|
||||
# ${{ env.APP_NAME }}_universal.ipa
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -62,3 +62,4 @@ ServerBox-x86_64.AppImage
|
||||
untranlated.json
|
||||
|
||||
.vscode/settings.json
|
||||
more_build_data.json
|
||||
|
||||
@@ -690,7 +690,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -700,7 +700,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -826,7 +826,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -836,7 +836,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -854,7 +854,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
@@ -864,7 +864,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -885,7 +885,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -898,7 +898,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
@@ -924,7 +924,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -937,7 +937,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -960,7 +960,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
@@ -973,7 +973,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -996,7 +996,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1008,7 +1008,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
@@ -1037,7 +1037,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1049,7 +1049,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
PRODUCT_NAME = ServerBox;
|
||||
@@ -1075,7 +1075,7 @@
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -1087,7 +1087,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
|
||||
PRODUCT_NAME = ServerBox;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// This file is generated by ./make.dart
|
||||
// This file is generated by make script. Do not edit.
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 912;
|
||||
static const String engine = "3.22.0";
|
||||
static const String buildAt = "2024-05-24 16:29:39";
|
||||
static const int modifications = 3;
|
||||
static const int build = 918;
|
||||
static const String engine = "3.22.1";
|
||||
static const String buildAt = "2024-05-25 19:17:18";
|
||||
static const int modifications = 2;
|
||||
static const int script = 48;
|
||||
}
|
||||
|
||||
@@ -72,5 +72,6 @@ abstract final class GithubIds {
|
||||
'pgs666',
|
||||
'FHU-yezi',
|
||||
'ZRY233',
|
||||
'Jasonzhu1207',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ final class _AppBar extends CustomAppBar {
|
||||
return ValBuilder(
|
||||
listenable: selectIndex,
|
||||
builder: (idx) {
|
||||
if (idx == AppTab.ssh.index && !isWindows && !isLinux) return placeholder;
|
||||
if (idx == AppTab.ssh.index && !isWindows && !isLinux) {
|
||||
return placeholder;
|
||||
}
|
||||
return super.build(context);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -471,7 +471,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
|
||||
@@ -481,7 +481,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "Server Box";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -608,7 +608,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
|
||||
@@ -618,7 +618,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "Server Box";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -638,7 +638,7 @@
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 912;
|
||||
CURRENT_PROJECT_VERSION = 918;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
"DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
@@ -649,7 +649,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MARKETING_VERSION = 1.0.912;
|
||||
MARKETING_VERSION = 1.0.918;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "Server Box";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
317
make.dart
317
make.dart
@@ -4,37 +4,23 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
const appName = 'ServerBox';
|
||||
final appNameLower = appName.toLowerCase();
|
||||
|
||||
const buildDataFilePath = 'lib/data/res/build_data.dart';
|
||||
const apkPath = 'build/app/outputs/flutter-apk/app-release.apk';
|
||||
const appleXCConfigPath = 'Runner.xcodeproj/project.pbxproj';
|
||||
const macOSArchievePath = 'build/macos/Build/Products/Release/server_box.app';
|
||||
const releaseDir = '/Volumes/pm981/release/serverbox';
|
||||
const shellScriptPath = 'lib/data/model/app/shell_func.dart';
|
||||
const uploadPathPrefix = 'cda:/var/www/res/';
|
||||
const moreBuildDataPath = 'more_build_data.json';
|
||||
|
||||
var regAppleProjectVer = RegExp(r'CURRENT_PROJECT_VERSION = .+;');
|
||||
var regAppleMarketVer = RegExp(r'MARKETING_VERSION = .+');
|
||||
|
||||
const buildFuncs = {
|
||||
'ios': flutterBuildIOS,
|
||||
'android': flutterBuildAndroid,
|
||||
'apk': flutterBuildAndroid,
|
||||
'mac': flutterBuildMacOS,
|
||||
'linux': flutterBuildLinux,
|
||||
'win': flutterBuildWin,
|
||||
};
|
||||
|
||||
int? build;
|
||||
|
||||
Future<void> getGitCommitCount() async {
|
||||
final result = await Process.run('git', ['log', '--format=format:%h']);
|
||||
build = (result.stdout as String)
|
||||
.split('\n')
|
||||
.where((line) => line.isNotEmpty)
|
||||
.length;
|
||||
void main(List<String> args) async {
|
||||
final cmd = args.firstOrNull;
|
||||
switch (cmd) {
|
||||
case 'before':
|
||||
final data = {
|
||||
'script': await getScriptCommitCount(),
|
||||
};
|
||||
await File(moreBuildDataPath).writeAsString(json.encode(data));
|
||||
break;
|
||||
case 'after':
|
||||
// Pass
|
||||
default:
|
||||
throw 'Invalid argument: $cmd';
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> getScriptCommitCount() async {
|
||||
@@ -49,276 +35,3 @@ Future<int> getScriptCommitCount() async {
|
||||
.where((line) => line.isNotEmpty)
|
||||
.length;
|
||||
}
|
||||
|
||||
Future<void> writeStaicConfigFile(
|
||||
Map<String, dynamic> data, String className, String path) async {
|
||||
final buffer = StringBuffer();
|
||||
buffer.writeln('// This file is generated by ./make.dart');
|
||||
buffer.writeln('');
|
||||
buffer.writeln('class $className {');
|
||||
for (var entry in data.entries) {
|
||||
final type = entry.value.runtimeType;
|
||||
final value = json.encode(entry.value);
|
||||
buffer.writeln(' static const $type ${entry.key} = $value;');
|
||||
}
|
||||
buffer.writeln('}');
|
||||
await File(path).writeAsString(buffer.toString());
|
||||
}
|
||||
|
||||
Future<int> getGitModificationCount() async {
|
||||
final result =
|
||||
await Process.run('git', ['ls-files', '-mo', '--exclude-standard']);
|
||||
return (result.stdout as String)
|
||||
.split('\n')
|
||||
.where((line) => line.isNotEmpty)
|
||||
.length;
|
||||
}
|
||||
|
||||
Future<String> getFlutterVersion() async {
|
||||
final result = await Process.run('flutter', ['--version'], runInShell: true);
|
||||
final stdout = result.stdout as String;
|
||||
return stdout.split('\n')[0].split('•')[0].split(' ')[1].trim();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getBuildData() async {
|
||||
final data = {
|
||||
'name': appName,
|
||||
'build': build,
|
||||
'engine': await getFlutterVersion(),
|
||||
'buildAt': DateTime.now().toString().split('.').firstOrNull,
|
||||
'modifications': await getGitModificationCount(),
|
||||
'script': await getScriptCommitCount(),
|
||||
};
|
||||
return data;
|
||||
}
|
||||
|
||||
String jsonEncodeWithIndent(Map<String, dynamic> json) {
|
||||
const encoder = JsonEncoder.withIndent(' ');
|
||||
return encoder.convert(json);
|
||||
}
|
||||
|
||||
Future<void> updateBuildData() async {
|
||||
print('Updating BuildData...');
|
||||
final data = await getBuildData();
|
||||
print(jsonEncodeWithIndent(data));
|
||||
await writeStaicConfigFile(data, 'BuildData', buildDataFilePath);
|
||||
}
|
||||
|
||||
Future<void> dartFormat() async {
|
||||
final result = await Process.run('dart', ['format', '.'], runInShell: true);
|
||||
print(result.stdout);
|
||||
if (result.exitCode != 0) {
|
||||
print(result.stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getFileSha256(String path) async {
|
||||
final result = await Process.run('shasum', ['-a', '256', path]);
|
||||
final stdout = result.stdout as String;
|
||||
return stdout.split(' ')[0];
|
||||
}
|
||||
|
||||
Future<void> flutterBuild(String buildType) async {
|
||||
final args = [
|
||||
'build',
|
||||
buildType,
|
||||
'--build-number=$build',
|
||||
'--build-name=1.0.$build',
|
||||
];
|
||||
final skslPath = '$buildType.sksl.json';
|
||||
if (await File(skslPath).exists()) {
|
||||
args.add('--bundle-sksl-path=$skslPath');
|
||||
}
|
||||
final isAndroid = 'apk' == buildType;
|
||||
if (isAndroid) {
|
||||
// Only arm64
|
||||
args.add('--target-platform=android-arm64');
|
||||
}
|
||||
print('\n[$buildType]\nBuilding with args: ${args.join(' ')}');
|
||||
final buildResult = await Process.run('flutter', args, runInShell: true);
|
||||
final exitCode = buildResult.exitCode;
|
||||
|
||||
if (exitCode != 0) {
|
||||
print(buildResult.stdout);
|
||||
print(buildResult.stderr);
|
||||
exit(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> flutterBuildIOS() async {
|
||||
await flutterBuild('ipa');
|
||||
}
|
||||
|
||||
Future<void> flutterBuildMacOS() async {
|
||||
await flutterBuild('macos');
|
||||
}
|
||||
|
||||
Future<void> flutterBuildAndroid() async {
|
||||
await flutterBuild('apk');
|
||||
await killJava();
|
||||
await scpApk2CDN();
|
||||
}
|
||||
|
||||
Future<void> flutterBuildLinux() async {
|
||||
await flutterBuild('linux');
|
||||
const appDirName = 'linux.AppDir';
|
||||
// cp -r build/linux/x64/release/bundle/* appName.AppDir
|
||||
await Process.run('cp', [
|
||||
'-r',
|
||||
'build/linux/x64/release/bundle',
|
||||
appDirName,
|
||||
]);
|
||||
// cp -r assets/app_icon.png ServerBox.AppDir
|
||||
await Process.run('cp', [
|
||||
'-r',
|
||||
'./assets/app_icon.png',
|
||||
appDirName,
|
||||
]);
|
||||
// Create AppRun
|
||||
const appRun = '''
|
||||
#!/bin/sh
|
||||
cd "\$(dirname "\$0")"
|
||||
exec ./$appName
|
||||
''';
|
||||
const appRunName = '$appDirName/AppRun';
|
||||
await File(appRunName).writeAsString(appRun);
|
||||
// chmod +x AppRun
|
||||
await Process.run('chmod', ['+x', appRunName]);
|
||||
// Create .desktop
|
||||
const desktop = '''
|
||||
[Desktop Entry]
|
||||
Name=$appName
|
||||
Exec=$appName
|
||||
Icon=app_icon
|
||||
Type=Application
|
||||
Categories=Utility;
|
||||
''';
|
||||
await File('$appDirName/default.desktop').writeAsString(desktop);
|
||||
// Run appimagetool
|
||||
await Process.run('sh', ['-c', 'ARCH=x86_64 appimagetool $appDirName']);
|
||||
|
||||
await scpLinux2CDN();
|
||||
}
|
||||
|
||||
Future<void> flutterBuildWin() async {
|
||||
await flutterBuild('windows');
|
||||
//await scpWindows2CDN();
|
||||
}
|
||||
|
||||
Future<void> scpApk2CDN() async {
|
||||
final result = await Process.run(
|
||||
'scp',
|
||||
[apkPath, '$uploadPathPrefix$appNameLower/$appName-$build.apk'],
|
||||
runInShell: true,
|
||||
);
|
||||
if (result.exitCode != 0) {
|
||||
print(result.stderr);
|
||||
exit(1);
|
||||
}
|
||||
print('Upload $build.apk finished.');
|
||||
}
|
||||
|
||||
Future<void> scpLinux2CDN() async {
|
||||
final result = await Process.run(
|
||||
'scp',
|
||||
[
|
||||
'$appName-x86_64.AppImage',
|
||||
'$uploadPathPrefix$appNameLower/$appName-$build.AppImage',
|
||||
],
|
||||
runInShell: true,
|
||||
);
|
||||
if (result.exitCode != 0) {
|
||||
print(result.stderr);
|
||||
exit(1);
|
||||
}
|
||||
print('Upload $build.AppImage finished.');
|
||||
}
|
||||
|
||||
Future<void> scpWindows2CDN() async {
|
||||
final result = await Process.run(
|
||||
'scp',
|
||||
[
|
||||
'./build/windows/runner/Release/$appName.zip',
|
||||
'$uploadPathPrefix$appNameLower/$appName-$build.zip',
|
||||
],
|
||||
runInShell: true,
|
||||
);
|
||||
if (result.exitCode != 0) {
|
||||
print(result.stderr);
|
||||
exit(1);
|
||||
}
|
||||
print('Upload $build.zip finished.');
|
||||
}
|
||||
|
||||
Future<void> changeAppleVersion() async {
|
||||
for (final path in ['ios', 'macos']) {
|
||||
final file = File('$path/$appleXCConfigPath');
|
||||
final contents = await file.readAsString();
|
||||
final newContents = contents
|
||||
.replaceAll(regAppleMarketVer, 'MARKETING_VERSION = 1.0.$build;')
|
||||
.replaceAll(regAppleProjectVer, 'CURRENT_PROJECT_VERSION = $build;');
|
||||
await file.writeAsString(newContents);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> killJava() async {
|
||||
/// Due to the high cost of Mac memory,
|
||||
/// terminate Java processes to free up memory.
|
||||
/// :)
|
||||
if (!Platform.isMacOS) return;
|
||||
final result = await Process.run('ps', ['-A']);
|
||||
final lines = (result.stdout as String).split('\n');
|
||||
for (final line in lines) {
|
||||
if (line.contains('java')) {
|
||||
final pid = line.split(' ')[0];
|
||||
print('Killing java process: $pid');
|
||||
await Process.run('kill', [pid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(List<String> args) async {
|
||||
if (args.isEmpty) {
|
||||
print('No action. Exit.');
|
||||
return;
|
||||
}
|
||||
|
||||
final command = args[0];
|
||||
switch (command) {
|
||||
case 'build':
|
||||
await dartFormat();
|
||||
await getGitCommitCount();
|
||||
// always change version to avoid dismatch version between different
|
||||
// platforms
|
||||
await changeAppleVersion();
|
||||
await updateBuildData();
|
||||
|
||||
final funcs = <Future<void> Function()>[];
|
||||
|
||||
if (args.length > 1) {
|
||||
final platforms = args[1];
|
||||
for (final platform in platforms.split(',')) {
|
||||
if (buildFuncs.keys.contains(platform)) {
|
||||
funcs.add(buildFuncs[platform]!);
|
||||
} else {
|
||||
print('Unknown platform: $platform');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
funcs.addAll(buildFuncs.values);
|
||||
}
|
||||
|
||||
final stopwatch = Stopwatch();
|
||||
for (final func in funcs) {
|
||||
stopwatch.start();
|
||||
await func();
|
||||
print('Build finished in ${stopwatch.elapsed}');
|
||||
stopwatch.reset();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print('Unsupported command: $command');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
4
make.json
Normal file
4
make.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"appName": "ServerBox",
|
||||
"beforeBuild": "./make.dart before"
|
||||
}
|
||||
11
pubspec.lock
11
pubspec.lock
@@ -388,6 +388,15 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
fl_build:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
path: "."
|
||||
ref: "8e1e3500fac2a39a43bed68aeb3cbdf792a1bd35"
|
||||
resolved-ref: "8e1e3500fac2a39a43bed68aeb3cbdf792a1bd35"
|
||||
url: "https://github.com/lollipopkit/fl_build.git"
|
||||
source: git
|
||||
version: "1.0.0"
|
||||
fl_chart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -650,7 +659,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
icons_plus:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: icons_plus
|
||||
sha256: "8e2f601b8605d45dd55b106a0da084a1809125077a49574ca22e8bcd5b6e86f0"
|
||||
|
||||
@@ -47,7 +47,6 @@ dependencies:
|
||||
ref: master
|
||||
url: https://github.com/lollipopkit/dart_computer
|
||||
flutter_background_service: ^5.0.5
|
||||
icons_plus: ^5.0.0
|
||||
fl_chart: ^0.67.0
|
||||
wakelock_plus: ^1.2.4
|
||||
extended_image: ^8.2.0
|
||||
@@ -74,6 +73,11 @@ dev_dependencies:
|
||||
flutter_lints: ^3.0.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
fl_build:
|
||||
# path: ../fl_build
|
||||
git:
|
||||
url: https://github.com/lollipopkit/fl_build.git
|
||||
ref: 8e1e3500fac2a39a43bed68aeb3cbdf792a1bd35
|
||||
|
||||
flutter:
|
||||
generate: true
|
||||
|
||||
Reference in New Issue
Block a user