DEV Community

Cover image for Build and Publish a Multi-Platform Electron App on GitHub

Build and Publish a Multi-Platform Electron App on GitHub

Erik Hofer on December 31, 2020

Introduction Create Electron Application Build on Linux, Windows and macOS Publish Release to GitHub Draft Releases Outlook Introductio...
Collapse
 
greggman profile image
Greggman • Edited

If I understand correctly you probably want to change npm install to npm ci. npm install will use the latest compatible dependencies where as npm ci will use what's in package-lock.json.

Collapse
 
erikhofer profile image
Erik Hofer

Yeah, that is a good hint! :)

Collapse
 
abulka profile image
Andy Bulka

Thanks for a great article. You have a typo in the use of 'draft' - which needs to be outside the repository json config, not inside it. It should look like:

"publishers": [
  {
    "name": "@electron-forge/publisher-github",
    "config": {
      "repository": {
        "owner": "erikhofer",
        "name": "hello-electron"
      },
    "draft": true
    }
  }
]
Enter fullscreen mode Exit fullscreen mode

Also, as you are no doubt aware, there is a shorthand way of specifying jobs for all operating systems, which means a much shorter yml workflow file and no duplication of lines needed.

jobs:
  release:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]

    steps:
    - uses: actions/checkout@v2       
    - uses: actions/setup-node@master
      with:
        node-version: 14
    - name: install dependencies
      run: npm install
    - name: publish
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: npm run publish
Enter fullscreen mode Exit fullscreen mode

Hoping you write some follow up articles about auto-updating and code signing!

Collapse
 
erikhofer profile image
Erik Hofer

Ah thanks, fixed the draft typo.

I've seen the matrix build before but it didn't come to mind at the time. Thanks for the addition, it's much more concise!

Collapse
 
abhi0725 profile image
Abhishek Chakravarty

Hi @erikhofer thanks for the article. One thing I want to know: Can this be done with private repo?

Collapse
 
erikhofer profile image
Erik Hofer

Thanks! I haven't tried it yet but I think yes.
If you need to use a special authToken, this can be configured: js.electronforge.io/publisher/gith...
Also note that GitHub Actions has an execution time quota for private repos, see github.com/pricing

Collapse
 
asrivdev profile image
Ashish Srivastava • Edited

I am trying this on a private repo. All the steps run fine including the Release step, but I dont see any other files in assets (I mean an executable for the electron app after publishing) . See attached image.

Collapse
 
thanhlm profile image
Thanh Minh

Thanksss. It help me lots

Collapse
 
kashi_zu profile image
Mak

Great article. How long did it take before the executables were added to your release?

Collapse
 
erikhofer profile image
Erik Hofer

Thanks! It mainly depends on the build time of the application, in the example it's about 3 minutes.

Collapse
 
chrisehlee profile image
cezer

Is it normal to be asked my npm credentials when I run electron-forge publish? Curious as I didn't expect my app to be published to npm and publicly too.

Collapse
 
ldiasdev profile image
Luis Gustavo de Oliveira Dias

Great article! It was exactly what I was looking for.

Collapse
 
tanner profile image
Tanner T

Receiving the following error when running build.yml

Run npm run make npm ERR! missing script: make

Collapse
 
erikhofer profile image
Erik Hofer

Do you have a script named make in your package.json like here github.com/erikhofer/electron-publ... ?

You could also use npx electron-forge make instead of npm run make if you want no extra script for it.