fix:热更新对比补充
This commit is contained in:
1 parent
b503cb7e6e
commit
2a88320228
2 files changed
+36
-6
No files matched your search
@@ -1,9 +1,18 @@
|
|||||||
.PHONY: runner run test lint apk ipa build-web
|
.PHONY: runner run test lint apk ipa build-web rename_release_apk jinzhi_shorebird_android jinzhi_shorebird_ios jinzhi_shorebird_android_patch jinzhi_shorebird_ios_patch
|
||||||
|
|
||||||
WEB_API_URL ?= https://jinzhi.api.local
|
WEB_API_URL ?= https://jinzhi.api.local
|
||||||
WEB_BASE_HREF ?= /flutter/
|
WEB_BASE_HREF ?= /flutter/
|
||||||
|
SHOREBIRD_TOKEN_FILE ?= $(HOME)/.shorebird_tokens/jinzhi.env
|
||||||
|
SHOREBIRD = if [ ! -f "$(SHOREBIRD_TOKEN_FILE)" ]; then echo "错误: 缺少 Shorebird token 文件: $(SHOREBIRD_TOKEN_FILE)"; exit 1; fi; set -a; . "$(SHOREBIRD_TOKEN_FILE)"; set +a; shorebird
|
||||||
GITVERSION := $(shell git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)
|
GITVERSION := $(shell git describe --tags --always --dirty 2>/dev/null || git rev-parse --short HEAD)
|
||||||
COMMON_DART_DEFINES := --dart-define=GITVERSION=$(GITVERSION)
|
RELEASE_VERSION ?= latest
|
||||||
|
PATCH_TRACK ?= staging
|
||||||
|
COMMON_DART_DEFINES := --dart-define="GITVERSION=$(GITVERSION)"
|
||||||
|
APP_VERSION := $(shell sed -n 's/^version: *//p' pubspec.yaml | head -n 1)
|
||||||
|
APK_VERSION_NAME := $(subst .,,${word 1,$(subst +, ,$(APP_VERSION))})
|
||||||
|
APK_VERSION_CODE := $(word 2,$(subst +, ,$(APP_VERSION)))
|
||||||
|
RELEASE_APK := jinzhi-$(APK_VERSION_NAME)-$(APK_VERSION_CODE)-release.apk
|
||||||
|
RELEASE_APK_DIR := build/app/outputs/flutter-apk
|
||||||
|
|
||||||
runner:
|
runner:
|
||||||
dart run build_runner build --delete-conflicting-outputs
|
dart run build_runner build --delete-conflicting-outputs
|
||||||
@@ -18,10 +27,29 @@ lint:
|
|||||||
flutter analyze
|
flutter analyze
|
||||||
|
|
||||||
apk:
|
apk:
|
||||||
flutter build apk $(COMMON_DART_DEFINES) --release --target-platform android-arm64
|
flutter build apk --obfuscate --split-debug-info=./build/symbos $(COMMON_DART_DEFINES) --release --target-platform android-arm64
|
||||||
|
$(MAKE) rename_release_apk
|
||||||
|
|
||||||
|
rename_release_apk:
|
||||||
|
@test -f "$(RELEASE_APK_DIR)/app-release.apk" || (echo "错误: 未找到 release APK: $(RELEASE_APK_DIR)/app-release.apk"; exit 1)
|
||||||
|
cp "$(RELEASE_APK_DIR)/app-release.apk" "$(RELEASE_APK_DIR)/$(RELEASE_APK)"
|
||||||
|
@echo "Release APK: $(RELEASE_APK_DIR)/$(RELEASE_APK)"
|
||||||
|
|
||||||
ipa:
|
ipa:
|
||||||
flutter build ipa $(COMMON_DART_DEFINES) --release
|
flutter build ipa --obfuscate --split-debug-info=./build/symbos $(COMMON_DART_DEFINES) --release
|
||||||
|
|
||||||
|
jinzhi_shorebird_android:
|
||||||
|
$(SHOREBIRD) release android --flutter-version=3.35.6 --split-debug-info=./build/symbos --target-platform android-arm64 --artifact apk -- --dart-define="GITVERSION=$(GITVERSION)"
|
||||||
|
$(MAKE) rename_release_apk
|
||||||
|
|
||||||
|
jinzhi_shorebird_ios:
|
||||||
|
$(SHOREBIRD) release ios --flutter-version=3.35.6 --split-debug-info=./build/symbos -- --dart-define="GITVERSION=$(GITVERSION)"
|
||||||
|
|
||||||
|
jinzhi_shorebird_android_patch:
|
||||||
|
$(SHOREBIRD) patch --platforms=android --release-version=$(RELEASE_VERSION) --split-debug-info=./build/symbos --track=$(PATCH_TRACK) -- --dart-define="GITVERSION=$(GITVERSION)"
|
||||||
|
|
||||||
|
jinzhi_shorebird_ios_patch:
|
||||||
|
$(SHOREBIRD) patch --platforms=ios --release-version=$(RELEASE_VERSION) --split-debug-info=./build/symbos --track=$(PATCH_TRACK) -- --dart-define="GITVERSION=$(GITVERSION)"
|
||||||
|
|
||||||
build-web:
|
build-web:
|
||||||
API_BASE_URL=$(WEB_API_URL) BASE_HREF=$(WEB_BASE_HREF) bash scripts/build_web.sh
|
API_BASE_URL=$(WEB_API_URL) BASE_HREF=$(WEB_BASE_HREF) bash scripts/build_web.sh
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
@@ -29,8 +30,9 @@ Future<Widget> bootstrap() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
await ShorebirdService.instance.initCurrentPatch();
|
// Shorebird's native updater performs the automatic launch-time update.
|
||||||
ShorebirdService.instance.checkForUpdateInBackground();
|
// Reading the running patch is diagnostic state and must not delay startup.
|
||||||
|
unawaited(ShorebirdService.instance.initCurrentPatch());
|
||||||
}
|
}
|
||||||
return const JinzhiApp();
|
return const JinzhiApp();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user