Skip to main content

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

· 5 min read

今天我们发布了一个免费的开源托管 更新网络服务 及其配套的 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 应用开发者来说,启用这些更新一直是部署进程中的一个繁琐步骤,因为它需要部署和维护一个网络服务器,仅仅为了提供应用版本历史的元数据。

🌐 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 网络服务集成的 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 的 Nucleus。有关更多信息,请参阅 [部署更新服务器] 教程。

🌐 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 帮助设计和构建这个简单且可扩展的网络服务。感谢 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 应用拥有一个常青的未来!