Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Configuring auto-update for an Electron app#
This is almost really simple. I used electron/update-electron-app for it, the instructions for which are:
- Add it to
packages.jsonwithnpm i update-electron-app - Make sure your
"repository"field in that file points to your GitHub repository - Use GitHub releases to release signed versions of your application
- Add
require('update-electron-app')()somewhere in yourmain.js
I added this… and it didn’t work (#106).
Then I spotted this recipe in the manual setup instructions for the update.electronjs.org server that it uses:
1const server = 'https://update.electronjs.org'2const feed = `${server}/OWNER/REPO/${process.platform}-${process.arch}/${app.getVersion()}`I ran that in the Electron debugger, swapping in simonw/datasette-app as the OWNER/REPO and got this URL:
https://update.electronjs.org/simonw/datasette-app/darwin-x64/0.2.0
Which returned this:
No updates found (needs asset matching *{mac,darwin,osx}*.zip in public repository)
It turns out your asset filename needs to match that pattern!
I renamed the asset I was attaching to the release to Datasette-mac.app.zip and the auto-update mechanism started working instantly.
How it works#
That update URL is interesting. If you hit it with the most recent version of the software (0.2.1 at time of writing) you get this:
1~ % curl -i 'https://update.electronjs.org/simonw/datasette-app/darwin-x64/0.2.1'2HTTP/1.1 204 No Content3Server: Cowboy4Content-Length: 05Connection: keep-alive6Date: Tue, 14 Sep 2021 03:54:47 GMT7Via: 1.1 vegurBut if you tell it you are running a previous version you get this instead:
1~ % curl -i 'https://update.electronjs.org/simonw/datasette-app/darwin-x64/0.2.0'2HTTP/1.1 200 OK3Server: Cowboy4Connection: keep-alive5Content-Type: application/json6Date: Tue, 14 Sep 2021 03:55:19 GMT7Content-Length: 7408Via: 1.1 vegur9
10{"name":"0.2.1","notes":"- Fixed bug where application would not start without a working internet connection. [#115](https://github.com/simonw/datasette-app/issues/115)\r\n- The \"Debug -> Open Chromium DevTools\" menu item no longer shows an error if no windows are focused. [#113](https://github.com/simonw/datasette-app/issues/113)\r\n- Fixed bug where the `datasette-leaflet` plugin could be uninstalled despite being automatically re-installed. [#118](https://github.com/simonw/datasette-app/issues/118)\r\n- Time limit for facet calculations increased from 1 second to 3 seconds. [#114](https://github.com/simonw/datasette-app/issues/114)","url":"https://github.com/simonw/datasette-app/releases/download/0.2.1/Datasette-mac.app.zip"}Which pretty-prints to:
1{2 "name": "0.2.1",3 "notes": "- Fixed bug where application would not start without a working internet connection. [#115](https://github.com/simonw/datasette-app/issues/115)\r\n- The \"Debug -> Open Chromium DevTools\" menu item no longer shows an error if no windows are focused. [#113](https://github.com/simonw/datasette-app/issues/113)\r\n- Fixed bug where the `datasette-leaflet` plugin could be uninstalled despite being automatically re-installed. [#118](https://github.com/simonw/datasette-app/issues/118)\r\n- Time limit for facet calculations increased from 1 second to 3 seconds. [#114](https://github.com/simonw/datasette-app/issues/114)",4 "url": "https://github.com/simonw/datasette-app/releases/download/0.2.1/Datasette-mac.app.zip"5}