|
22 | 22 | <!-- START doctoc generated TOC please keep comment here to allow auto update --> |
23 | 23 | <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
24 | 24 |
|
25 | | -- [auto\_updater](#auto_updater) |
26 | | - - [平台支持](#平台支持) |
27 | | - - [快速开始](#快速开始) |
28 | | - - [安装](#安装) |
29 | | - - [⚠️ Windows requirements](#️-windows-requirements) |
30 | | - - [用法](#用法) |
31 | | - - [发布你的应用](#发布你的应用) |
32 | | - - [生成私钥](#生成私钥) |
33 | | - - [macOS](#macos) |
34 | | - - [Windows](#windows) |
35 | | - - [打包应用](#打包应用) |
36 | | - - [macOS](#macos-1) |
37 | | - - [Windows](#windows-1) |
38 | | - - [获取签名](#获取签名) |
39 | | - - [macOS](#macos-2) |
40 | | - - [Windows](#windows-2) |
41 | | - - [分发应用](#分发应用) |
42 | | - - [故障排除](#故障排除) |
43 | | - - [macOS](#macos-3) |
44 | | - - [谁在用使用它?](#谁在用使用它) |
45 | | - - [API](#api) |
46 | | - - [AutoUpdater](#autoupdater) |
47 | | - - [Methods](#methods) |
48 | | - - [setFeedURL](#setfeedurl) |
49 | | - - [checkForUpdates](#checkforupdates) |
50 | | - - [setScheduledCheckInterval](#setscheduledcheckinterval) |
51 | | - - [相关链接](#相关链接) |
52 | | - - [许可证](#许可证) |
| 25 | +- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81) |
| 26 | +- [文档](#%E6%96%87%E6%A1%A3) |
| 27 | +- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83) |
| 28 | +- [API](#api) |
| 29 | + - [AutoUpdater](#autoupdater) |
| 30 | + - [Methods](#methods) |
| 31 | + - [setFeedURL](#setfeedurl) |
| 32 | + - [checkForUpdates](#checkforupdates) |
| 33 | + - [setScheduledCheckInterval](#setscheduledcheckinterval) |
| 34 | +- [相关链接](#%E7%9B%B8%E5%85%B3%E9%93%BE%E6%8E%A5) |
| 35 | +- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81) |
53 | 36 |
|
54 | 37 | <!-- END doctoc generated TOC please keep comment here to allow auto update --> |
55 | 38 |
|
|
59 | 42 | | :---: | :---: | :-----: | |
60 | 43 | | ➖ | ✔️ | ✔️ | |
61 | 44 |
|
62 | | -## 快速开始 |
| 45 | +## 文档 |
63 | 46 |
|
64 | | -### 安装 |
65 | | - |
66 | | -将此添加到你的软件包的 pubspec.yaml 文件: |
67 | | - |
68 | | -```yaml |
69 | | -dependencies: |
70 | | - auto_updater: ^0.2.0 |
71 | | -``` |
72 | | -
|
73 | | -或 |
74 | | -
|
75 | | -```yaml |
76 | | -dependencies: |
77 | | - auto_updater: |
78 | | - git: |
79 | | - path: packages/auto_updater |
80 | | - url: https://github.com/leanflutter/auto_updater.git |
81 | | - ref: main |
82 | | -``` |
83 | | -
|
84 | | -#### ⚠️ Windows requirements |
85 | | -
|
86 | | -- `openssl` |
87 | | - |
88 | | -运行以下命令: |
89 | | - |
90 | | -> 使用 [Chocolatey](https://chocolatey.org/install) |
91 | | - |
92 | | -``` |
93 | | -choco install openssl |
94 | | -``` |
95 | | -
|
96 | | -### 用法 |
97 | | -
|
98 | | -```dart |
99 | | -import 'package:auto_updater/auto_updater.dart'; |
100 | | -
|
101 | | -void main() async { |
102 | | - // 必须加上这一行。 |
103 | | - WidgetsFlutterBinding.ensureInitialized(); |
104 | | -
|
105 | | - String feedURL = 'http://localhost:5002/appcast.xml'; |
106 | | - await autoUpdater.setFeedURL(feedURL); |
107 | | - await autoUpdater.checkForUpdates(); |
108 | | - await autoUpdater.setScheduledCheckInterval(3600); |
109 | | -
|
110 | | - runApp(MyApp()); |
111 | | -} |
112 | | -``` |
113 | | - |
114 | | -> 请看这个插件的示例应用,以了解完整的例子。 |
115 | | -
|
116 | | -### 发布你的应用 |
117 | | - |
118 | | -#### 生成私钥 |
119 | | - |
120 | | -运行以下命令: |
121 | | - |
122 | | -```bash |
123 | | -dart run auto_updater:generate_keys |
124 | | -``` |
125 | | - |
126 | | -> 需要分别在 `macOS` 和 `Windows` 系统中运行该命令。 |
127 | | -
|
128 | | -##### macOS |
129 | | - |
130 | | -准备使用 `EdDSA` 签名算法进行签名: |
131 | | - |
132 | | -输出: |
133 | | - |
134 | | -``` |
135 | | -A key has been generated and saved in your keychain. Add the `SUPublicEDKey` key to |
136 | | -the Info.plist of each app for which you intend to use Sparkle for distributing |
137 | | -updates. It should appear like this: |
138 | | -
|
139 | | - <key>SUPublicEDKey</key> |
140 | | - <string>pfIShU4dEXqPd5ObYNfDBiQWcXozk7estwzTnF9BamQ=</string> |
141 | | -``` |
142 | | - |
143 | | -更改文件 `macos/Runner/Info.plist` 如下: |
144 | | - |
145 | | -```diff |
146 | | -<?xml version="1.0" encoding="UTF-8"?> |
147 | | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
148 | | -<plist version="1.0"> |
149 | | -<dict> |
150 | | - |
151 | | - ... |
152 | | - |
153 | | -+ <key>SUPublicEDKey</key> |
154 | | -+ <string>bHaXClrRGMmKoKP/3HJnr/jn2ODTRPAM3VZhhkI9ZvY=</string> |
155 | | -</dict> |
156 | | -</plist> |
157 | | -``` |
158 | | - |
159 | | -##### Windows |
160 | | - |
161 | | -准备使用 `DSA` 签名算法进行签名: |
162 | | - |
163 | | -输出: |
164 | | - |
165 | | -``` |
166 | | -Generated two files: |
167 | | -dsa_priv.pem: your private key. Keep it secret and don't share it! |
168 | | -dsa_pub.pem: public counterpart to include in youe app. |
169 | | -BACK UP YOUR PRIVATE KEY AND KEEP IT SAFE! |
170 | | -If you lose it, your users will be unable to upgrade! |
171 | | -``` |
172 | | - |
173 | | -> 命令将为你生成私钥(`dsa_priv.pem`)及公钥(`dsa_pub.pem`),请备份你的私钥并确保其安全,并将公钥作为 Windows 资源添加到项目中。 |
174 | | -
|
175 | | -更改文件 `windows/runner/Runner.rc` 如下: |
176 | | - |
177 | | -```diff |
178 | | - |
179 | | -... |
180 | | - |
181 | | -+///////////////////////////////////////////////////////////////////////////// |
182 | | -+// |
183 | | -+// WinSparkle |
184 | | -+// |
185 | | - |
186 | | -+// And verify signature using DSA public key: |
187 | | -+DSAPub DSAPEM "../../dsa_pub.pem" |
188 | | -``` |
189 | | - |
190 | | -#### 打包应用 |
191 | | - |
192 | | -> 为了简化打包的过程,这里使用了 [Fastforge](https://fastforge.dev) ,一个专门用于打包和发布 Flutter 应用的完整工具。 |
193 | | -
|
194 | | -将 `distribute_options.yaml` 添加到你的项目根目录。 |
195 | | - |
196 | | -```yaml |
197 | | -output: dist/ |
198 | | -releases: |
199 | | - - name: prod |
200 | | - jobs: |
201 | | - - name: macos-zip |
202 | | - package: |
203 | | - platform: macos |
204 | | - target: zip |
205 | | - build_args: |
206 | | - dart-define: |
207 | | - APP_ENV: dev |
208 | | - # 查看完整文档:https://fastforge.dev/makers/exe |
209 | | - - name: windows-exe |
210 | | - package: |
211 | | - platform: windows |
212 | | - target: exe |
213 | | - build_args: |
214 | | - dart-define: |
215 | | - APP_ENV: dev |
216 | | -``` |
217 | | -
|
218 | | -##### macOS |
219 | | -
|
220 | | -运行以下命令: |
221 | | -
|
222 | | -``` |
223 | | -fastforge release --name prod --jobs macos-zip |
224 | | -``` |
225 | | - |
226 | | -##### Windows |
227 | | - |
228 | | -运行以下命令: |
229 | | - |
230 | | -``` |
231 | | -fastforge release --name prod --jobs windows-exe |
232 | | -``` |
233 | | - |
234 | | -#### 获取签名 |
235 | | - |
236 | | -##### macOS |
237 | | - |
238 | | -运行以下命令: |
239 | | - |
240 | | -``` |
241 | | -dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-macos.zip |
242 | | -``` |
243 | | - |
244 | | -输出: |
245 | | - |
246 | | -``` |
247 | | -sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA==" length="13400992" |
248 | | -``` |
249 | | - |
250 | | -将获得的新签名更新到 `appcast.xml` 文件 `enclosure` 节点的 `sparkle:edSignature` 属性值。 |
251 | | - |
252 | | -##### Windows |
253 | | - |
254 | | -运行以下命令: |
255 | | - |
256 | | -``` |
257 | | -dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-windows-setup.exe |
258 | | -``` |
259 | | - |
260 | | -输出: |
261 | | - |
262 | | -``` |
263 | | -
|
264 | | -sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk=" length="13400992" |
265 | | -``` |
266 | | - |
267 | | -将获得的新签名更新到 `appcast.xml` 文件 `enclosure` 节点的 `sparkle:dsaSignature` 属性值。 |
268 | | - |
269 | | -#### 分发应用 |
270 | | - |
271 | | -将 `appcast.xml` 添加到你的项目 `dist/` 目录。 |
272 | | - |
273 | | -```xml |
274 | | -<?xml version="1.0" encoding="UTF-8"?> |
275 | | -<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"> |
276 | | - <channel> |
277 | | - <title>auto_updater_example</title> |
278 | | - <description>Most recent updates to auto_updater_example</description> |
279 | | - <language>en</language> |
280 | | - <item> |
281 | | - <title>Version 1.1.0</title> |
282 | | - <!-- 对于 macOS 项目,建议将 'sparkle:version' 和 'sparkle:shortVersionString' 添加到项目节点中,而不是作为 'enclosure' 的一部分。 --> |
283 | | - <sparkle:version>2</sparkle:version> |
284 | | - <sparkle:shortVersionString>1.1.0</sparkle:shortVersionString> |
285 | | - <sparkle:releaseNotesLink> |
286 | | - https://your_domain/your_path/release_notes.html |
287 | | - </sparkle:releaseNotesLink> |
288 | | - <pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate> |
289 | | - <enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-macos.zip" |
290 | | - sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA==" |
291 | | - sparkle:os="macos" |
292 | | - length="13400992" |
293 | | - type="application/octet-stream" /> |
294 | | - </item> |
295 | | - <item> |
296 | | - <title>Version 1.1.0</title> |
297 | | - <sparkle:releaseNotesLink> |
298 | | - https://your_domain/your_path/release_notes.html |
299 | | - </sparkle:releaseNotesLink> |
300 | | - <pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate> |
301 | | - <enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-windows.exe" |
302 | | - sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk=" |
303 | | - sparkle:version="1.1.0+2" |
304 | | - sparkle:os="windows" |
305 | | - length="0" |
306 | | - type="application/octet-stream" /> |
307 | | - </item> |
308 | | - </channel> |
309 | | -</rss> |
310 | | -``` |
311 | | - |
312 | | -> 本示例中 `macOS` 和 `Windows` 使用同一个 `appcast.xml` 文件,你需根据配置 `sparkle:os` 属性的值。 |
313 | | -
|
314 | | -启动测试更新服务器: |
315 | | - |
316 | | -``` |
317 | | -cd dist/ |
318 | | -serve -l 5002 |
319 | | -``` |
320 | | - |
321 | | -## 故障排除 |
322 | | - |
323 | | -### macOS |
324 | | - |
325 | | -- 确保按照 [Sparkle 文档](https://sparkle-project.org/documentation/)中的说明添加了 sparkle pod |
326 | | -- 通过将以下内容添加到您的授权文件以进行调试和发布,确保您已添加并启用应用程序的网络功能并禁用沙箱以进行发布 |
327 | | - |
328 | | -``` |
329 | | -<key>com.apple.security.network.client</key> |
330 | | - <true/> |
331 | | -<key>com.apple.security.network.server</key> |
332 | | - <true/> |
333 | | -<key>com.apple.security.app-sandbox</key> |
334 | | - <false/> |
335 | | -``` |
| 47 | +- [快速开始](https://leanflutter.dev/zh/documentation/auto_updater/quick-start) |
| 48 | +- [API 参考](https://pub.dev/documentation/auto_updater/latest/auto_updater/) |
| 49 | +- [更新日志](https://pub.dev/packages/auto_updater/changelog) |
336 | 50 |
|
337 | 51 | ## 谁在用使用它? |
338 | 52 |
|
|
0 commit comments