release_updater 是一个 Flutter/Dart 包,可简化在本地目录中自动更新发布或安装文件的过程。它使开发者能够通过从远程源获取并替换它们来管理版本化的资源,例如应用二进制文件或配置文件。适用于需要频繁更新而无需完全重新安装的应用程序,支持 Android、iOS、macOS、Windows 和 Linux 等多个平台。该包通过减少手动文件管理并确保跨环境的一致性,简化了部署工作流程。
适合场景
自动化应用资源更新
管理带版本的安装文件
将本地构建与远程发布同步
优化CI/CD流水线
部署后更新配置文件
主要特点
自动文件替换
远程源集成
跨平台支持
简单的 CLI 命令
版本感知更新
适合对象
开发人员管理频繁的应用程序更新
使用自动化部署工作流的团队
具有分布式构建产物的项目
CI/CD 流水线集成
需要本地文件同步的应用程序
使用建议
需要网络访问以进行更新
远程源配置的手动设置
仅限本地目录更新
不适用于运行时应用程序更新
依赖外部文件的可用性
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
release_updater
This package brings a simple way to automatically update release/installation files in a local directory.
It also comes with built-in CLI tools to easily generate a release bundle (Zip file) or
serve release files for multiple platforms.
Motivation
Since Dart can run in many native platforms (Linux/x64, macOS/x64/arm64, Windows/x86),
it's not simple to manage all the different releases+platforms files that a
compiled Dart application can have.
In the same way that modern Browsers, and many other applications,
can have automatic builds and updates for multiple platforms, this package
provides tools and an API to easily achieve that.
API Documentation
See the API Documentation for a full list of functions, classes and extension.
Usage
import'dart:io';
import'package:release_updater/release_updater_io.dart';
voidmain() async {
var storage = ReleaseStorageDirectory('appx', Directory('/install/path'));
var provider = ReleaseProviderHttp.baseURL('https://your.domain/appx/releases');
var releaseUpdater = ReleaseUpdater(storage, provider);
var version = await releaseUpdater.update();
print('» Updated to version: $version');
var runResult = await releaseUpdater.runReleaseProcess('run.exe', ['-a']);
var exitCode = runResult!.exitCode;
print('» Exit code: $exitCode');
print('» Result: ${runResult.stdout}');
exit(exitCode);
}
ReleaseProvider
You can implement your own ReleaseProvider or use just the built-in ReleaseProviderHttp class.
CLI Tools
release_updater: A CLI updater.
release_updater_server: A simple HTTP server to provide releases using the shelf package.
version_from: the JSON or YAML file to provide the field version (if the parameter field is not provided).
platform: is a RegExp string to match the building platform. See the ReleasePlatform class.
Command types:
dart_pub_get: performs a dart pub get.
dart_compile_exe: performs a dart compile exe %dart_script.
dart: performs a dart %command.
windows_gui: Changes an executable Windows Subsistem to GUI.
command: performs a shell %command.
rm: Deletes a file.
upload_release: uploads the generated release.
url: release server base URL.
authorization: HTTP basic authorization.
username: authentication username.
password: authentication password.
Command errors:
A command that fails aborts the build: the error is logged, the
remaining commands are NOT executed, and the release_packer CLI
exits with code 1. This avoids a silent error generating and
releasing an incomplete package/artifact.
Some commands are just ignored (skipped) when not applicable, and do
NOT abort the build:
rm of a file that doesn't exist.
windows_gui over a file that is not a Windows executable (the usual
case when building on another platform).
files: each entry of files can be:
A String with a file path:
"file/path.txt"
A Map with extra parameters:
A file with a renamed path and a specific platform.