publish configuration in electron-builder controls how artifacts and update info files are published for auto-update. Publishing can be configured for multiple providers simultaneously.
Configuration
Thepublish key accepts:
String: Provider name (e.g.,"github","s3","spaces")Object: Provider configuration with optionsArray<Object | String>: Multiple providers
Order matters! The first item in the array will be used as the default auto-update server.
publish configuration in:
- Top-level configuration
- Platform-specific configuration (
mac,linux,win) - Target-specific configuration (e.g.,
nsis)
Auto-Detection
electron-builder automatically detects publish providers based on environment variables:- If
GH_TOKENorGITHUB_TOKENis defined → defaults to[{provider: "github"}] - If
KEYGEN_TOKENis defined (and GitHub tokens are not) → defaults to[{provider: "keygen"}] - If
GITHUB_RELEASE_TOKENis defined → used instead ofGH_TOKEN/GITHUB_TOKENfor publishing
Multiple Publishers
You can publish to multiple providers. The first provider will be used as the default auto-update server:How to Publish
The--publish CLI flag controls when to publish:
| Value | Description |
|---|---|
onTag | Publish only on tag push |
onTagOrDraft | Publish on tag push or if draft release exists |
always | Always publish |
never | Never publish |
Automatic Publishing Rules
Instead of explicitly specifying--publish, electron-builder follows these automatic rules:
- CI server detected →
onTagOrDraft - Tag pushed in CI →
onTag(release drafted if doesn’t exist, artifacts published only on tag push) - npm script named
release→always
npm run release or yarn release will draft a release (if doesn’t exist) and publish artifacts.
Publishing Workflows
GitHub Releases Workflow (Recommended)
Draft a new release
Draft a new release on GitHub. Set the “Tag version” to your application’s
package.json version prefixed with v.Example: If your package.json version is 1.0, set “Tag version” to v1.0.Push commits
Push commits to your repository. Every CI build will update the artifacts attached to this draft release.
This workflow allows you to always have the latest artifacts, and the release can be published when ready.
Continuous Deployment on S3 and Non-GitHub Providers
This workflow is modeled on Maven release handling:Use snapshot versions during development
Set your
package.json version to 1.9.0-snapshot (or 1.9.0-master). This will publish:snapshot.ymlmetadata filesomething-snapshot.exebuild (and corresponding files for other platforms)
Deploy production version
When ready to deploy, change your version to
1.9.0 and push. This will produce:latest.ymlmetadata filesomething.exebuild
GitHub Repository Detection
The GitHub repository is automatically detected from:repositoryfield inpackage.json- Environment variables:
TRAVIS_REPO_SLUGAPPVEYOR_REPO_NAMECIRCLE_PROJECT_USERNAME/CIRCLE_PROJECT_REPONAME
.git/configorigin URL
Publishers
GitHub
Publish to GitHub Releases:GH_TOKENorGITHUB_TOKEN: GitHub personal access tokenGITHUB_RELEASE_TOKEN: Optional separate token for publishing (allows read-onlyGITHUB_TOKEN)
For fine-grained personal access tokens, “Contents” permission with “Read and write” access is sufficient.
S3
Publish to Amazon S3:AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
DigitalOcean Spaces
Publish to DigitalOcean Spaces:DO_KEY_ID: DigitalOcean Spaces access keyDO_SECRET_KEY: DigitalOcean Spaces secret key
Keygen
Publish to Keygen:KEYGEN_TOKEN: Keygen API token
Bitbucket
Publish to Bitbucket:Snap Store
Thesnap target publishes to Snap Store by default:
To force publishing to a different provider, explicitly specify the publish configuration for
snap.Generic Server (BYO)
Publish to your own generic HTTP(s) server:File Macros
All publish options support File Macros for dynamic values:Generated Files
electron-builder generates and uploads the following metadata files (except forbintray which doesn’t require them):
- Windows:
latest.yml - macOS:
latest-mac.yml - Linux:
latest-linux.yml
- Version information
- File paths
- SHA-512 checksums
- Optional staging percentage for rollouts
latest.yml:
CI Configuration Examples
GitHub Actions
.github/workflows/build.yml
Travis CI
.travis.yml