publish key contains a set of options instructing electron-builder on how it should publish artifacts and build update info files for auto update.
Configuration Format
String | Object | Array<Object | String> where Object can be any of the provider configurations below.
Order is important - the first item will be used as a default auto-update server. Can be specified in the top-level configuration or any platform- (mac, linux, win) or target- (e.g. nsis) specific configuration.
When using a generic server, you have to upload the built application and metadata files yourself.
Default Behavior
- If
GH_TOKENorGITHUB_TOKENis defined - defaults to[{provider: "github"}] - If
KEYGEN_TOKENis defined andGH_TOKENorGITHUB_TOKENis not - defaults to[{provider: "keygen"}] - If
GITHUB_RELEASE_TOKENis defined, it will be used instead ofGH_TOKENorGITHUB_TOKENto publish your release- The
GITHUB_TOKENwill still be used when your app checks for updates - You could make your
GITHUB_TOKEN“Read-only” when creating a fine-grained personal access token, and “Read and write” for theGITHUB_RELEASE_TOKEN - “Contents” fine-grained permission was sufficient (as of Apr 2024)
- The
Snap Store:
snap target by default publishes to snap store (the app store for Linux). To force publishing to another provider, explicitly specify publish configuration for snap.Multiple Publishers
You can publish to multiple providers. Order is important - the first item will be used as a default auto-update server.How to Publish
CLI Options
| Value | Description |
|---|---|
onTag | On tag push only |
onTagOrDraft | On tag push or if draft release exists |
always | Always publish |
never | Never publish |
Automatic Rules
Instead of explicitly specifying--publish, you can rely on automatic rules:
- CI server detected -
onTagOrDraft - CI server reports tag was pushed -
onTag(Release will be drafted if doesn’t already exist and artifacts published only if tag was pushed) - npm script named
release-always
scripts in your development package.json:
npm run release to draft a release and publish artifacts.
Workflows
Recommended GitHub Releases Workflow
- Draft a new release. Set the “Tag version” to the value of
versionin your applicationpackage.json, and prefix it withv. “Release title” can be anything you want.- For example, if your application
package.jsonversion is1.0, your draft’s “Tag version” would bev1.0
- For example, if your application
- Push some commits. Every CI build will update the artifacts attached to this draft.
- Once you are done, publish the release. GitHub will tag the latest commit for you.
Continuous Deployment Workflow on Amazon S3
This example workflow is modelled on how releases are handled in maven (it is an example of one of many possible workflows):- Setup your CI to publish on each commit. E.g.
"dist": "electron-builder --publish always"in yourpackage.json - Set your version in your application
package.jsonto1.9.0-snapshot(or1.9.0-masteror whatever you want your development channel to be named). This will publish a file namedsnapshot.ymland a build namedsomething-snapshot.exe(and corresponding for mac) to S3. - When you are ready to deploy, simply change your package version to
1.9.0and push. This will then produce alatest.ymlandsomething.exeon S3. Usually you’ll git-tag this version as well (just to keep track of it). - Change the version back to a snapshot version right after, i.e.
1.10.0-snapshot, and commit it.
GitHub Repository Detection
Detected automatically using:- repository in the application or development
package.json - If not set, from environment variables:
TRAVIS_REPO_SLUGAPPVEYOR_REPO_NAMECIRCLE_PROJECT_USERNAME/CIRCLE_PROJECT_REPONAME
- If no environment variables, from
.git/configorigin url
File Macros
In all publish options File Macros are supported.Base Configuration
All publish providers extend these base configuration options:The provider name (github, s3, spaces, generic, etc.)
Whether to publish auto update info files.Auto update relies only on the first provider in the list (you can specify several publishers). Thus, probably, there’s no need to upload the metadata files for the other configured providers. But by default will be uploaded.
Any custom request headers
Request timeout in milliseconds. (Default is 2 minutes; 0 is ignored)
GitHub
GitHub options. GitHub personal access token is required. You can generate by going to https://github.com/settings/tokens/new. The access token should have the repo scope/permission. DefineGH_TOKEN environment variable.
Must be
githubThe repository name. Detected automatically.
The owner
Whether to use
v-prefixed tag name.If defined, sets the prefix of the tag name that comes before the semver number.Examples:
"v" in "v1.2.3" or "test" in "test1.2.3"Overrides vPrefixedTagNameThe host (including the port if needed)
The protocol. GitHub Publisher supports only
https.The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for setFeedURL.
Whether to use private github auto-update provider if
GH_TOKEN environment variable is defined. See Private GitHub Update Repo.The channel
The type of release. By default
draft release will be created.Also you can set release type using environment variable. If EP_DRAFT is set to true - draft, if EP_PRE_RELEASE is set to true - prerelease.Example
GitLab
GitLab options. GitLab personal access token is required for private repositories. You can generate one by going to your GitLab profile settings. DefineGITLAB_TOKEN environment variable.
Must be
gitlabThe GitLab project ID or path (e.g., “12345678” or “namespace/project”)
The GitLab host (including the port if needed)
The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.
Whether to use
v-prefixed tag nameThe channel
Upload target method. Can be “project_upload” for GitLab project uploads or “generic_package” for GitLab generic packages.
Example
Amazon S3
Amazon S3 options. AWS credentials are required, please see getting your credentials. To set credentials defineAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables directly, or use ~/.aws/credentials file, or use ~/.aws/config file. For the last method to work you will also need to define AWS_SDK_LOAD_CONFIG=1 environment variable.
Must be
s3The bucket name
The region. Is determined and set automatically when publishing.
The update channel
The directory path
The ACL. Set to
null to not add.Please see required permissions for the S3 provider.The type of storage to use for the object
Server-side encryption algorithm to use for the object
The endpoint URI to send requests to. The default endpoint is built from the configured region.The endpoint should be a string like
https://{service}.{region}.amazonaws.com.If set to true, this will enable the s3 accelerated endpoint.These endpoints have a particular format of:
${bucketname}.s3-accelerate.amazonaws.comWhen true, force a path-style endpoint to be used where the bucket name is part of the path.Path-style Access
Example
DigitalOcean Spaces
DigitalOcean Spaces options. Access key is required, defineDO_KEY_ID and DO_SECRET_KEY environment variables.
Must be
spacesThe space name
The region (e.g.
nyc3)The update channel
The directory path
The ACL. Set to
null to not add.Example
Keygen
Keygen options. DefineKEYGEN_TOKEN environment variable.
Must be
keygenKeygen account’s UUID
Keygen product’s UUID
Keygen host for self-hosted instances
The channel
The target Platform. Is set programmatically explicitly during publishing.
Example
Bitbucket
Bitbucket options. DefineBITBUCKET_TOKEN environment variable.
For converting an app password to a usable token, you can utilize this:
Must be
bitbucketRepository owner
Repository slug/name
The app password to support auto-update from private bitbucket repositories.
The user name to support auto-update from private bitbucket repositories
The channel
Example
Snap Store
Snap Store options. To publish directly to Snapcraft, see Snapcraft authentication options for local or CI/CD authentication options.Must be
snapStoreSnapcraft repo name
The list of channels the snap would be released
Example
Generic Server
Generic (any HTTP(S) server) options. In all publish options File Macros are supported.When using a generic server, you have to upload the built application and metadata files yourself.
Must be
genericThe base url. e.g.
https://bucket_name.s3.amazonaws.comThe channel
Whether to use multiple range requests for differential update. Defaults to
true if url doesn’t contain s3.amazonaws.com.Example
Custom Publisher
Custom publish provider can be used if needed.Must be
customThe Provider to provide UpdateInfo regarding available updates. Required to use custom providers with electron-updater.