New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New guide for implementing updates #10251
Changes from 6 commits
bb1627a
c1a40fb
3815ed8
06f4c1b
cfe914f
01f31ed
837a34c
235ae09
6a872dd
3405596
78f11df
3062027
4ba4fe4
68250d8
35b2bc6
2ec223b
a84d49f
5f82168
78c87d4
1731359
b6787db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Updating Applications | ||
|
||
There are several ways to update an Electron application. The easiest and officially supported one is taking advantage of the built-in [Squirrel](https://github.com/Squirrel) framework and the [autoUpdater](../api/auto-updater.md) module that comes with it. | ||
|
||
## Deploying an Update Server | ||
|
||
To get started, you firstly need to deploy an update server (that's where the [autoUpdater](../api/auto-updater.md) module will download new updates from). | ||
|
||
Depending on your needs, you can choose from one of these: | ||
|
||
- [Hazel](https://github.com/zeit/hazel) – Pulls new releases from [GitHub Releases](https://help.github.com/articles/creating-releases/) and is **perfect for getting started** | ||
- [Nuts](https://github.com/GitbookIO/nuts) – Also uses [GitHub Releases](https://help.github.com/articles/creating-releases/), but caches app updates on disk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but caches app updates on disk, therefore allowing use of private GitHub repositories There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 837a34c |
||
- [electron-release-server](https://github.com/ArekSredzki/electron-release-server) – Provides you with a dashboard for handling releases | ||
|
||
## Implementing Updates into Your App | ||
|
||
Once you've deployed your update server, continue with importing the required modules in your code (the following code might vary for different server software, but it works like described when using [Hazel](https://github.com/zeit/hazel)). | ||
|
||
**Important:** Please ensure that the code below will only be executed in production - you can use [electron-is-dev](https://github.com/sindresorhus/electron-is-dev) to check for the environment). | ||
|
||
```js | ||
const { app, autoUpdater } = require('electron') | ||
``` | ||
|
||
Next, put together the URL of the update server: | ||
|
||
```js | ||
const server = <your-deployment-url> | ||
const feed = `${server}/update/${process.platform}/${app.getVersion()}` | ||
``` | ||
|
||
As the final step, tell [autoUpdater](../api/auto-updater.md) where to ask for updates: | ||
|
||
```js | ||
autoUpdater.setFeedURL(feed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea as well! 👍 235ae09 |
||
``` | ||
|
||
That's all. Once [built](../tutorial/application-distribution.md), your application will receive an update for each new [GitHub Release](https://help.github.com/articles/creating-releases/) that you create. | ||
|
||
## Further Steps | ||
|
||
Now that you've configured the basic update mechanism for your application, you need to ensure that the user will get notified when there's an update (this can be achieved using [events](../api/auto-updater.md#events)). | ||
|
||
Also make sure that potential errors are [being handled](../api/auto-updater.md#event-error). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leo why did this section on Windows and Linux get removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it wasn't necessary, but now - after thinking about it a bit more - I brought it back just to be sure that we're all on the same page: 3405596 and 78f11df