electron / update.electronjs.org

📡 A free service that makes it easy for open-source Electron apps to update themselves.
610 stars 73 forks source link

📡 update.electronjs.org

A free service that makes it easy for open-source Electron apps to update themselves.

CircleCI build status

Requirements

Before using this service, make sure your Electron app meets these criteria:

Quick Setup

Install update-electron-app as a runtime dependency (not a devDependency):

npm install update-electron-app --save

Call it from in your main process file:

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

And that's all it takes! To customize, see the update-electron-app API.

Once your application is packaged, it will update itself for each new GitHub Release that you publish.

Manual Setup

Use something like the following setup to add automatic updates to your application:

Important: Please ensure that the code below will only be executed in your packaged app, and not in development. You can use electron-is-dev to check for the environment.

const { app, autoUpdater } = require('electron')

Next, construct the URL of the update server and tell autoUpdater about it:

const server = 'https://update.electronjs.org'
const feed = `${server}/OWNER/REPO/${process.platform}-${process.arch}/${app.getVersion()}`

autoUpdater.setFeedURL(feed)

As the final step, check for updates. The example below will check every 10 minutes:

setInterval(() => {
  autoUpdater.checkForUpdates()
}, 10 * 60 * 1000)

Once your application is packaged, it will update itself for each new GitHub Release that you publish.

Routes

/:owner/:repo/:platform/:version

/:owner/:repo/win32/:version/RELEASES

Development

You'll first need to have a running Redis server. There are two options:

1) Locally: Install Redis locally and run it directly with redis-server. Guides can be found here. 2) Docker: Install and run Redis with docker run -p 6379:6379 -it redis/redis-stack-server:latest.

$ yarn
$ GH_TOKEN=TOKEN npm start

To try with an actual electron app, run:

$ yarn start &
$ cd example
$ yarn

On Darwin:

$ npm run build
$ ./out/test-darwin-x64/test.app/Contents/MacOS/test

On Windows:

$ npm run build
$ "example\out\make\squirrel.windows\x64\test-0.0.0 Setup.exe"