Skip to content
Latchkey

CI/CD for an Electron + electron-builder Release with GitHub Actions

Build Electron installers on three OSes and publish them with electron-builder.

electron-builder packages an Electron app into per-OS installers (dmg, nsis, AppImage) and can publish them to a GitHub release. This recipe runs a matrix across macOS, Windows, and Linux on a tag.

What the pipeline does

  • matrix over macOS, Windows, and Ubuntu
  • install deps with npm ci
  • build the renderer and main bundles
  • package and publish with electron-builder
  • attach installers to the GitHub release

The workflow

electron-builder --publish always uploads to the GitHub release when GH_TOKEN is set. Each matrix OS produces its native installer; code signing uses per-OS secrets.

.github/workflows/release.yml
name: Release
on:
  push:
    tags: ["v*"]
jobs:
  release:
    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npm run build
      - name: Package and publish
        run: npx electron-builder --publish always
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CSC_LINK: ${{ secrets.CSC_LINK }}
          CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}

Caching and speed

cache: npm restores installs; cache the electron-builder download cache (~/.cache/electron and ~/.cache/electron-builder) so prebuilt binaries are reused. Packaging on three OSes is the costly part, so cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) cut the macOS and Windows cost most, and auto-retry covers a flaky binary download.

Deploying

With --publish always, electron-builder uploads each OS installer and the auto-update metadata (latest.yml and friends) to the GitHub release for the tag, so electron-updater clients can auto-update. Provide signing secrets so installers are trusted on macOS and Windows.

Key takeaways

  • Use a three-OS matrix to build native Electron installers.
  • electron-builder --publish always uploads to the GitHub release.
  • Publish latest.yml so electron-updater clients can auto-update.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →