By David Ng, Product & Growth, Oursky

So you’ve used Electron to build an amazing cross-platform application with JavaScript, HTML and CSS. What happens if you’ve updated? How will you push your updates to your users’ platform?



We wanted to make auto-updating Electron apps painless. Therefore, we developed an open source backend implementation for to manage release information more easily.

Automating the Squirrel framework with the autoUpdater module

We created the Electron autoUpdater module to provide an interface for the Squirrel framework.

Squirrel checks for new releases and handles an upgrade for (including downloading the new build and installing it upon restart). From the client side, that’s everything you need for Electron. However, Squirrel needs an endpoint, which means we needed a server to host. We wanted to host our build information on the cloud as well for convenience.

Here is a brief flow of how the auto update is done:

First, Squirrel will check for updates from the endpoint server. The server’s main job is to fetch information from the GitHub repository assigned. If the new release is different from the current app, Squirrel will trigger an update.

How do they communicate? The little Squirrel tells the endpoint what platform and version the current app is on:

The server then compares it with the latest version. If the latest version > current version, it responds with the URL pointing to the latest version:

{

"url": "http://mycompany.com/myapp/releases/latest",

}

If no update is required, your server must respond with a status code of 204 No Content. Squirrel will check for an update again at the interval specified.

Manage your releases on GitHub

To release a new version of the application, we need to package it for Mac and Windows respectively. We recommend using electron-builder. Here is the minimal electron-builder configuration:

{

"appId": "<your app id>",

"mac": {

"target": ["zip"],

},

"win": {

"target": "squirrel",

},

"squirrelWindows": {

"useAppIdAsId": true

}

}

With the above configuration, we will get

a .zip for the Mac application

for the Mac application a RELEASES , a .nupkg and a .exe for the Windows application. The .nupkg is for squirrel update, and the .exe is for first time installation.

Then we need to host the app releases and the endpoint server for Squirrel somewhere. We appreciate simplicity. We find storing assets using GitHub release can simplify the process in these ways:

Don’t have to set up a database

Don’t need to manually check for new releases

Set up an authentication system easily

We can just push a tag — if we have set up our automatic build tool. A CI tool will do the build job and pin up a release. Alternatively, we could also manually add a new release and all the assets files.