How to create release channels with electron/electron-builder?
Asked Answered
D

3

7

I have an Electron app where I want to introduce parallel release channels: stable, next (for early adopters) and dev (for testing the latest build).

These will have a branch each, with new features appearing first in dev, progressing to next for beta testing and finally moving into stable.

I'm using electron-builder to make these release packages, and I want each to have its own auto-updates - so when I publish a new next release all the users with it get the update.

I want the applications to be independent - a user can have two channels installed and run both at the same time. They'll have different names and different icons.

I can manually set these up in the branches, but really I want to automate this as much as possible - a publish from the next branch should use the right name, icons, IDs and updater without risk of it going to the wrong channel.

Is there a way to do this with electron or electron-builder?

Dyan answered 24/11, 2016 at 10:26 Comment(0)
P
10

It's possible with electron-builder. I would have several build configurations and tell electron-builder which to use when building.

For example, create file config/beta.json with the following setup:

{
  "appId": "com.company.beta",
  "productName": "App Beta",
  "directories": {
    "buildResources": "build/beta" // directory containing your build-specific assets (e.g., beta icons - icon.icns, icon.ico & background.png)
  },
  "mac": {
    "category": "public.app-category.finance"
  },
  "win": {
    "target": [
      "nsis"
    ]
  },
  "nsis": {
    "perMachine": false
  },
  "publish": [
    {
      "provider": "s3",
      "bucket": "com-app-beta" // dedicated S3 bucket for each build
    }
  ],
}

And duplicate config/beta.json for next.json and current.json (make sure to edit settings accordingly).

In package.json, add the following build scripts (note --em.name=app-beta to overwrite package.json's "name" value):

{
    "scripts": {
        "build": "build -owl --x64 --config ./config/current.json -p always --em.name=app",
        "build-beta": "build -owl --x64 --config ./config/beta.json -p always --em.name=app-beta",
        "build-next": "build -owl --x64 --config ./config/next.json -p always --em.name=app-next"
    }
}

Run build script when ready to deploy:

npm run build-beta
Putty answered 13/3, 2017 at 2:29 Comment(0)
P
3

Using electron-builder version 20.15.1 and MacOS, @Jon Saw's solution needs a minor change because em option is not valid:

"build-beta": "build -owl --x64 --config ./config/beta.json -p always -c.extraMetadata.name=app-beta"
Papiamento answered 4/7, 2018 at 14:58 Comment(1)
Hi, thanks for the feedback and welcome to SO. This would be better as a comment on Jon Saw's answer, as that way they'll get a notification.Dyan
M
0

electron-builder(latest: v24.9.1) provides us with a way to distribute a pre-release version.

Three release channels are available: "latest", "beta" and "alpha." The default is "latest".

So, you can use "latest" as "stable", "beta" as "next", "alpha" as "dev".

It's simple to use it. If we want to build a beta version app, we add "-beta" to the version name in package.json.

"name": "my-electron-app",
"version": "1.2.3-beta",

After this change in package.json, the electron-builder outputs beta.yml instead of latest.yml when building. Of course, the file name of the built application is also changed to 1.2.3-beta.

Miyamoto answered 31/1 at 1:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.