Deploying
To sign on Mac, you need a developer account and a distribution certificate. Electron-build will auto pick up the cert if it exists
Way2 may be easy for private repos too
Way 1: AutoUpdate Server
Hazel
Easy zeit creation that pulls from github releases even for private repos
git clone https://github.com/zeit/hazel
cd hazel
#PUBLIC REPOS
now -e ACCOUNT="<github-account>" -e REPOSITORY="<github-repository>"
#Private REPOS
now --prod -e URL='https://<NOW DOMAIN>.now.sh' -e TOKEN="<GITHUB_TOKEN>" -e ACCOUNT="jsfuentes" -e REPOSITORY="Room"
Only run in the prod app version
const { app, autoUpdater } = require('electron')
const server = <your-deployment-url>
const feed = `${server}/update/${process.platform}/${app.getVersion()}`
autoUpdater.setFeedURL(feed)
setInterval(() => {
autoUpdater.checkForUpdates()
}, 600000) //check every 10 minutes
Notifying user
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) autoUpdater.quitAndInstall()
})
})
autoUpdater.on('error', message => {
console.error('There was a problem updating the application')
console.error(message)
})
Way 2: Electron-Updater
Easiest setup! Struggles with private repos, apparently private repos work here too
1)
npm install electron-updater
2) Configure publish in package.json under "build" key
3)
const { autoUpdater } = require("electron-updater")
export default class AppUpdater {
constructor() {
const log = require("electron-log");
log.transports.file.level = "info";
autoUpdater.logger = log;
autoUpdater.checkForUpdatesAndNotify();
}
}
//...createMainWindow function {
new AppUpdater();
}
Electron-updater Vs. built-in autoUpdater
Dedicated release server is not required.
Code signature validation on mac & win
All required metadata auto produced & published
Download progress and staged rollouts supported on all platforms.
Different providers supported out of the box (GitHub Releases, Amazon S3, DigitalOcean Spaces, Bintray and generic HTTP(s) server).
You need only 2 lines of code to make it work.
https://github.com/electron/electron/issues/7155)
Way 3, Electron Way:
Electron team maintains free update.electronjs.org for free apps in github releases
App runs on macOS or Windows
App has a public GitHub repository
Builds are published to GitHub Releases
Builds are code-signed
On Mac: App must be signed for auto updates, based on Squirrel.Mac
On WIndows: Make sure not to update app the [first time it runs](**
Last updated