Skip to main content

开源应用更轻松的自动更新

· 6 min read

今天,我们发布了免费、开源、托管的 更新 Web 服务 及其配套 npm 包,以便轻松实现开源 Electron 应用的自动更新。这是让应用开发者更少考虑部署,更多地关注为用户开发高质量体验的一步。

¥Today we're releasing a free, open-source, hosted updates webservice and companion npm package to enable easy automatic updates for open-source Electron apps. This is a step toward empowering app developers to think less about deployment and more about developing high-quality experiences for their users.


让生活更轻松

¥Making life easier

Electron 拥有 autoUpdater API,使应用能够使用来自远程端点的元数据来检查更新、在后台下载并自动安装。

¥Electron has an autoUpdater API that gives apps the ability to consume metadata from a remote endpoint to check for updates, download them in the background, and install them automatically.

对于许多 Electron 应用开发者来说,启用这些更新一直是部署过程中繁琐的一步,因为它需要部署和维护一个 Web 服务器来提供应用版本历史元数据。

¥Enabling these updates has been a cumbersome step in the deployment process for many Electron app developers because it requires a web server to be deployed and maintained just to serve app version history metadata.

今天,我们宣布推出一款用于自动应用更新的全新嵌入式解决方案。如果你的 Electron 应用位于公共 GitHub 仓库中,并且你使用 GitHub Releases 发布构建版本,则可以使用此服务向用户提供持续的应用更新。

¥Today we are announcing a new drop-in solution for automatic app updates. If your Electron app is in a public GitHub repository and you're using GitHub Releases to publish builds, you can use this service to deliver continuous app updates to your users.

使用新模块

¥Using the new module

为了最大限度地减少你的配置工作,我们创建了 update-electron-app,这是一个与新的 update.electronjs.org Web 服务集成的 npm 模块。

¥To minimize configuration on your part, we've created update-electron-app, an npm module which integrates with the new update.electronjs.org webservice.

安装模块:

¥Install the module:

npm install update-electron-app

可在应用的 主进程 中的任何位置调用:

¥Call it from anywhere in your app's main process:

require('update-electron-app')();

就是这样!该模块将在应用启动时检查更新,然后每十分钟检查一次。当发现更新时,它会在后台自动下载,并在更新准备就绪时显示一个对话框。

¥That's it! The module will check for updates at app startup, then every ten minutes. When an update is found it will download automatically in the background, and a dialog will be displayed when the update is ready.

迁移现有的应用

¥Migrating existing apps

已经使用 Electron autoUpdater API 的应用也可以使用此服务。为此,你可以使用 自定义 update-electron-app 模块或 直接与 update.electronjs.org 集成 模块。

¥Apps already using Electron's autoUpdater API can use this service too. To do so, you can customize the update-electron-app module or integrate directly with update.electronjs.org.

替代方案

¥Alternatives

如果你使用 electron-builder 打包应用,可以使用其内置的更新程序。详情请参阅 electron.build/auto-update

¥If you're using electron-builder to package your app, you can use its built-in updater. For details, see electron.build/auto-update.

如果你的应用是私有的,则可能需要运行自己的更新服务器。有很多开源工具可以实现这一点,包括 Zeit 的 Hazel 和 Atlassian 的 。请参阅 部署更新服务器 教程了解更多信息。

¥If your app is private, you may need to run your own update server. There are a number of open-source tools for this, including Zeit's Hazel and Atlassian's Nucleus. See the Deploying an Update Server tutorial for more info.

致谢

¥Thanks

感谢 Julian Gruber 帮助设计和构建这个简单且可扩展的 Web 服务。感谢 Zeit 的朋友们开源了 Hazel 服务,我们从中汲取了设计灵感。感谢 Samuel Attard 的代码审查。感谢 Electron 社区帮助测试这项服务。

¥Thanks to Julian Gruber for helping design and build this simple and scalable web service. Thanks to the folks at Zeit for their open-source Hazel service, from which we drew design inspiration. Thanks to Samuel Attard for the code reviews. Thanks to the Electron community for helping test this service.

🌲 祝 Electron 应用未来长青!

¥🌲 Here's to an evergreen future for Electron apps!