Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# - uses: actions/checkout@v3
# - uses: subosito/flutter-action@v2
# with:
# flutter-version: "3.24.3"
# flutter-version: "3.44.0"
# channel: "stable"
# - run: |
# sudo apt-get update
Expand All @@ -30,11 +30,12 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.24.3"
flutter-version: "3.44.0"
channel: "stable"
- uses: bluefireteam/melos-action@v3
- working-directory: ./packages/auto_updater/example
run: |
rm -rf "$HOME/Library/Caches/org.swift.swiftpm/artifacts"
flutter build macos --release

# build-web:
Expand All @@ -43,7 +44,7 @@ jobs:
# - uses: actions/checkout@v3
# - uses: subosito/flutter-action@v2
# with:
# flutter-version: "3.24.3"
# flutter-version: "3.44.0"
# channel: "stable"
# - uses: bluefireteam/melos-action@v3
# - working-directory: ./packages/auto_updater/example
Expand All @@ -56,7 +57,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.24.3"
flutter-version: "3.44.0"
channel: "stable"
- uses: bluefireteam/melos-action@v3
- working-directory: ./packages/auto_updater/example
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.24.3"
flutter-version: "3.44.0"
channel: "stable"
- uses: bluefireteam/melos-action@v3
- run: melos run analyze
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.24.3"
flutter-version: "3.44.0"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.24.3"
flutter-version: "3.44.0"
channel: "stable"
cache: true
- uses: bluefireteam/melos-action@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.dart_tool/
.build/
.swiftpm/
.idea/

*.iml
Expand Down
15 changes: 14 additions & 1 deletion docs/en/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ Run the following command:
choco install openssl
```

### ⚠️ macOS requirements

- Flutter `>=3.41.0`
- macOS deployment target `>=10.15`

The macOS implementation supports both Flutter's Swift Package Manager integration
and CocoaPods. It depends on Sparkle `>=2.9.2 <3.0`.

## Usage

```dart
Expand Down Expand Up @@ -65,6 +73,9 @@ dart run auto_updater:generate_keys
```

> You need to run this command on `macOS` and `Windows` systems separately.
> On macOS, this command uses the Sparkle tools from
> `AUTO_UPDATER_SPARKLE_BIN`, `macos/Pods/Sparkle/bin`, or
> `build/macos/SourcePackages/artifacts/sparkle/Sparkle/bin`.

#### macOS

Expand Down Expand Up @@ -263,7 +274,9 @@ serve -l 5002

### macOS

- Make sure you have the sparkle pod added as described in [Sparkle Documentation](https://sparkle-project.org/documentation/)
- If you use CocoaPods, make sure you have the Sparkle pod added as described in [Sparkle Documentation](https://sparkle-project.org/documentation/)
- If you use Swift Package Manager, run `flutter build macos` first so Xcode fetches Sparkle into `build/macos/SourcePackages/artifacts/sparkle/Sparkle/bin`.
- If Sparkle tools are installed somewhere else, set `AUTO_UPDATER_SPARKLE_BIN` to the directory containing `generate_keys` and `sign_update`.
- Make sure you have added and enabled network capabilties of your app and disabled the sandbox for release by adding the following to your entitlement files for debug and release

```
Expand Down
15 changes: 14 additions & 1 deletion docs/zh/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ dependencies:
choco install openssl
```

### ⚠️ macOS 要求

- Flutter `>=3.41.0`
- macOS 部署目标 `>=10.15`

macOS 实现同时支持 Flutter 的 Swift Package Manager 集成和 CocoaPods。它依赖
Sparkle `>=2.9.2 <3.0`。

## 用法

```dart
Expand Down Expand Up @@ -65,6 +73,9 @@ dart run auto_updater:generate_keys
```

> 需要分别在 `macOS` 和 `Windows` 系统中运行该命令。
> 在 macOS 上,该命令会从 `AUTO_UPDATER_SPARKLE_BIN`、
> `macos/Pods/Sparkle/bin` 或
> `build/macos/SourcePackages/artifacts/sparkle/Sparkle/bin` 查找 Sparkle 工具。

#### macOS

Expand Down Expand Up @@ -263,7 +274,9 @@ serve -l 5002

### macOS

- 确保按照 [Sparkle 文档](https://sparkle-project.org/documentation/)中的说明添加了 sparkle pod
- 如果使用 CocoaPods,请确保按照 [Sparkle 文档](https://sparkle-project.org/documentation/)中的说明添加了 Sparkle pod
- 如果使用 Swift Package Manager,请先运行 `flutter build macos`,让 Xcode 将 Sparkle 拉取到 `build/macos/SourcePackages/artifacts/sparkle/Sparkle/bin`
- 如果 Sparkle 工具安装在其他位置,请将 `AUTO_UPDATER_SPARKLE_BIN` 设置为包含 `generate_keys` 和 `sign_update` 的目录
- 通过将以下内容添加到您的授权文件以进行调试和发布,确保您已添加并启用应用程序的网络功能并禁用沙箱以进行发布

```
Expand Down
4 changes: 2 additions & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ scripts:
- test

format:
exec: dart format . --fix
exec: dart format .
description: Run `dart format` for all packages.

format-check:
exec: dart format . --fix --set-exit-if-changed
exec: dart format . --set-exit-if-changed
description: Run `dart format` checks for all packages.

fix:
Expand Down
6 changes: 6 additions & 0 deletions packages/auto_updater/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.1

* feat(macos): Add Swift Package Manager support for Sparkle.
* chore: Support Sparkle tools from CocoaPods, SwiftPM, or `AUTO_UPDATER_SPARKLE_BIN`.
* chore: Require Dart `>=3.11.0` and Flutter `>=3.41.0`.

## 1.0.0

* First major release.
Expand Down
25 changes: 4 additions & 21 deletions packages/auto_updater/bin/generate_keys.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;

import 'package:auto_updater/src/sparkle_tools.dart';

Future<void> main(List<String> arguments) async {
if (!(Platform.isMacOS || Platform.isWindows)) {
throw UnsupportedError('auto_updater:generate_keys');
}

String executable = Platform.isMacOS
? '${Directory.current.path}/macos/Pods/Sparkle/bin/generate_keys'
: p.joinAll(
[
Directory.current.path,
'windows',
'flutter',
'ephemeral',
'.plugin_symlinks',
'auto_updater_windows',
'windows',
'WinSparkle-0.8.1',
'bin',
'generate_keys.bat',
],
);
final executable = sparkleToolExecutable(SparkleTool.generateKeys);

Process process = await Process.start(
executable,
arguments,
);
final process = await Process.start(executable, arguments);

process.stdout.transform(utf8.decoder).listen(stdout.write);
process.stderr.transform(utf8.decoder).listen(stderr.write);
Expand Down
55 changes: 18 additions & 37 deletions packages/auto_updater/bin/sign_update.dart
Original file line number Diff line number Diff line change
@@ -1,61 +1,42 @@
import 'dart:io';

import 'package:auto_updater/src/sparkle_tools.dart';
import 'package:path/path.dart' as p;

class SignUpdateResult {
const SignUpdateResult({
required this.signature,
required this.length,
});
const SignUpdateResult({required this.signature, required this.length});

final String signature;
final int length;
}

SignUpdateResult signUpdate(List<String> args) {
String executable = Platform.isMacOS
? '${Directory.current.path}/macos/Pods/Sparkle/bin/sign_update'
: p.joinAll(
[
Directory.current.path,
'windows',
'flutter',
'ephemeral',
'.plugin_symlinks',
'auto_updater_windows',
'windows',
'WinSparkle-0.8.1',
'bin',
'sign_update.bat',
],
);
List<String> arguments = List<String>.from(args);
final executable = sparkleToolExecutable(SparkleTool.signUpdate);
final arguments = List<String>.from(args);
if (Platform.isWindows) {
if (arguments.length == 1) {
arguments.add(p.join('dsa_priv.pem'));
}
}

ProcessResult processResult = Process.runSync(
executable,
arguments,
);
final processResult = Process.runSync(executable, arguments);

int exitCode = processResult.exitCode;
final exitCode = processResult.exitCode;

String? signUpdateOutput;
if (exitCode == 0) {
signUpdateOutput = processResult.stdout.toString();
if (Platform.isWindows) {
signUpdateOutput = signUpdateOutput.replaceFirst('\r\n', '').trim();
signUpdateOutput = 'sparkle:dsaSignature="$signUpdateOutput" length="0"';
}
stdout.write(signUpdateOutput);
} else {
if (exitCode != 0) {
stderr.write(processResult.stderr);
throw Exception('Failed to sign update');
}

var signUpdateOutput = processResult.stdout.toString();
if (Platform.isWindows) {
signUpdateOutput = signUpdateOutput.replaceFirst('\r\n', '').trim();
signUpdateOutput = 'sparkle:dsaSignature="$signUpdateOutput" length="0"';
}
stdout.write(signUpdateOutput);

RegExp regex = RegExp(r'sparkle:(dsa|ed)Signature="([^"]+)" length="(\d+)"');
RegExpMatch? match = regex.firstMatch(signUpdateOutput!);
final regex = RegExp(r'sparkle:(dsa|ed)Signature="([^"]+)" length="(\d+)"');
final match = regex.firstMatch(signUpdateOutput);

if (match == null) {
throw Exception('Failed to sign update');
Expand Down
2 changes: 1 addition & 1 deletion packages/auto_updater/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _MyAppState extends State<MyApp> {
primaryColor: const Color(0xff416ff4),
canvasColor: Colors.white,
scaffoldBackgroundColor: const Color(0xffF7F9FB),
dividerColor: Colors.grey.withOpacity(0.3),
dividerColor: Colors.grey.withValues(alpha: 0.3),
),
builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()],
Expand Down
4 changes: 1 addition & 3 deletions packages/auto_updater/example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class _HomePageState extends State<HomePage> with UpdaterListener {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
appBar: AppBar(title: const Text('Plugin example app')),
body: _buildBody(context),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/auto_updater/example/macos/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :osx, '10.14'
platform :osx, '10.15'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
14 changes: 7 additions & 7 deletions packages/auto_updater/example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- auto_updater_macos (0.0.1):
- FlutterMacOS
- Sparkle
- Sparkle (< 3.0, >= 2.9.2)
- FlutterMacOS (1.0.0)
- screen_retriever_macos (0.0.1):
- FlutterMacOS
- Sparkle (2.5.2)
- Sparkle (2.9.2)
- window_manager (0.2.0):
- FlutterMacOS

Expand All @@ -30,12 +30,12 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos

SPEC CHECKSUMS:
auto_updater_macos: 3e3462c418fe4e731917eacd8d28eef7af84086d
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
auto_updater_macos: d1e475f6e51b1d442776389bc778918388c5a978
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
screen_retriever_macos: 776e0fa5d42c6163d2bf772d22478df4b302b161
Sparkle: 0e335e5c704ac28dbea18cc0383e15a3927c28dc
Sparkle: 2d0c930d42d53ee0fdf98bbb342c08eaf18ab5f0
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0

COCOAPODS: 1.14.3
COCOAPODS: 1.16.2
Loading