GitHub Action
Electron Builder Action
GitHub Action for building and releasing Electron apps
This is a GitHub Action for automatically building and releasing your Electron app using GitHub's CI/CD capabilities. It uses electron-builder
to package your app for macOS, Windows and Linux, and release it to a platform like GitHub Releases.
GitHub Actions allows you to build your app on all three platforms without having access to a machine/VM with each of these operating systems.
-
Install and configure
electron-builder
in your Electron app. You can read about this in the project's docs or in my blog post.Important: You no longer need an NPM script which runs
electron-builder
, this action will do that for you. -
If you are building for macOS, you'll want your code to be signed. GitHub Actions therefore needs access to your code signing certificate:
- Open the Keychain Access app or the Apple Developer Portal. Export all certificates related to your app into a single file (e.g.
certs.p12
) and set a strong password - Base64-encode your certificates using the following command:
base64 -i certs.p12 -o encoded.txt
- In your project's GitHub repository, go to Settings → Secrets and add the following two variables:
mac_certs
: Your encoded certificates, i.e. the content of theencoded.txt
file you created beforemac_certs_password
: The password you set when exporting the certificates
- Open the Keychain Access app or the Apple Developer Portal. Export all certificates related to your app into a single file (e.g.
-
Add a workflow file to your project (e.g.
.github/workflows/build.yml
):name: Build/release # Only run the workflow when a new tag is found on: push: tags: - "*" jobs: release: runs-on: ${{ matrix.os }} # Platforms to build on/for strategy: matrix: os: [macos-10.14, windows-2019, ubuntu-18.04] steps: - name: Check out Git repository uses: actions/checkout@v1 - name: Install Node.js and Yarn uses: actions/setup-node@v1 with: node-version: 10 - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@master with: github_token: ${{ secrets.github_token }} # Automatically generated mac_certs: ${{ secrets.mac_certs }} mac_certs_password: ${{ secrets.mac_certs_password }}
Please note: Before v1.0
, the action's behavior might still change. Instead of using the latest commit (samuelmeuli/action-electron-builder@master
), you might therefore want to pin a specific commit for now (e.g. samuelmeuli/action-electron-builder@4fef1fe
).
The action…
- Installs your dependencies
- Runs your
build
NPM script (necessary if you use preprocessors, module bundlers, etc. for your app) - Builds your app using
electron-builder
- Optionally releases your app
Suggestions and contributions are always welcome! Please discuss larger changes via issue before submitting a pull request.
This project is still WIP. The following needs to be implemented before v1.0
:
- Add support for NPM (besides Yarn)
- Make the
build
NPM script optional - In the sample workflow, add tag detection, which should decide whether to release after the build
- Add support for publishing to Snapcraft
- Add support for Windows code signing