Skip to content

Instantly share code, notes, and snippets.

@jtbandes
Created November 14, 2025 22:43
Show Gist options
  • Select an option

  • Save jtbandes/677df14872fbff5d2e7d01f53ccc455c to your computer and use it in GitHub Desktop.

Select an option

Save jtbandes/677df14872fbff5d2e7d01f53ccc455c to your computer and use it in GitHub Desktop.
# This is a GitHub Actions workflow to create Electron builds for macOS & Linux & Windows, both x64 & arm64.
on:
workflow_dispatch: {}
env:
ELECTRON_REVISION: v39.1.0
defaults:
run:
# Use bash by default, to avoid needing separate steps when accessing env vars on Windows ($X vs $env:X)
shell: bash
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
# Mac builds are run on a self-hosted runner (a Mac Studio).
- os: darwin
arch: x64
runs-on: mac-studio-24c-64gb
- os: darwin
arch: arm64
runs-on: mac-studio-24c-64gb
- os: linux
arch: x64
runs-on: ubuntu-2204-32c-128gb
- os: linux
arch: arm64
runs-on: ubuntu-2204-32c-128gb
- os: windows
arch: x64
runs-on: windows-2025-32c-128gb
- os: windows
arch: arm64
runs-on: windows-2025-32c-128gb
name: build-${{ matrix.config.os }}-${{ matrix.config.arch }}
runs-on: ${{ matrix.config.runs-on }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
# note: @electron/build-tools seems to run on Windows in a way that it finds the
# preinstalled version of node, instead of the one we install here.
node-version: 24
# Installing @electron/build-tools requires a pre-existing installation of yarn
- run: corepack enable
- run: corepack install -g yarn
- uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Set required git settings for electron-build-tools on windows
if: ${{ matrix.config.os == 'windows' }}
run: |
git config --global core.filemode false
git config --global core.autocrlf false
git config --global branch.autosetuprebase always
git config --global core.longpaths true
git config --global core.fscache true
git config --global core.preloadindex true
# Install dependencies needed for building Electron on linux
# https://github.com/electron/electron/blob/main/docs/development/build-instructions-linux.md
- if: ${{ matrix.config.os == 'linux' }}
run: |
sudo apt-get update && sudo apt-get install \
build-essential \
clang \
libdbus-1-dev \
libgtk-3-dev \
libnotify-dev \
libasound2-dev \
libcap-dev \
libcups2-dev \
libxtst-dev \
libxss1 \
libnss3-dev \
gcc-multilib \
g++-multilib \
curl \
gperf \
bison \
python3-dbusmock \
openjdk-8-jre
- run: npm i -g @electron/[email protected]
# We want to make a Release build
- run: e init my-builder --import release --target-cpu ${{ matrix.config.arch }}
# Add gclient args required for Linux arm64 build
# https://github.com/electron/electron/issues/40790#issuecomment-1911643339
- if: ${{ matrix.config.os == 'linux' && matrix.config.arch == 'arm64' }}
run: |
sed -i 's/"custom_vars": {},/"custom_vars": { "checkout_arm": True, "checkout_arm64": True },/g' electron/.gclient
- run: e sync --revision ${{ env.ELECTRON_REVISION }}
# Install Chromium dependencies needed for cross-compiling for Linux arm64
# https://source.chromium.org/chromium/chromium/src/+/main:docs/linux/chromium_arm.md
- if: ${{ matrix.config.os == 'linux' && matrix.config.arch == 'arm64' }}
run: electron/src/build/install-build-deps.sh
- run: e build
# Build the distribution zip file and name it according to the official release's naming convention
# (This allows electron-builder to find the right electron zips during the packaging process)
- run: e build electron:electron_dist_zip
- run: echo "OUTPUT_ZIP_NAME=electron-${{ env.ELECTRON_REVISION }}-${{ matrix.config.os }}-${{ matrix.config.arch }}.zip" >> $GITHUB_ENV
- run: mv electron/src/out/Release/dist.zip "$OUTPUT_ZIP_NAME"
- uses: actions/upload-artifact@v5
with:
name: ${{ env.OUTPUT_ZIP_NAME }}
path: ${{ env.OUTPUT_ZIP_NAME }}
# Files are zipped again when uploading artifacts. Since we already have a zip file we
# don't need more compression.
compression-level: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment