Skip to main content
The electron-publish module provides the publishing infrastructure used by electron-builder to upload artifacts to various hosting providers.

Installation

PublishOptions Interface

Options for controlling when to publish artifacts.
PublishPolicy | null
When to publish artifacts.
  • "onTag" - Publish only if building a tagged commit
  • "onTagOrDraft" - Publish on tag or if GitHub release is a draft
  • "always" - Always publish
  • "never" - Never publish

PublishContext Interface

Context provided to publishers.
CancellationToken
Token for cancelling upload operations.
MultiProgress | null
Progress bar manager for displaying upload progress.

UploadTask Interface

Represents a file to be uploaded.
string
required
Path to the file to upload.
Buffer | null
Optional file content buffer (instead of reading from file path).
Arch | null
Architecture of the artifact (or null if not architecture-specific).
string | null
Safe artifact name for display/logging.
number | null
Upload timeout in milliseconds.

Publisher Classes

Base class and platform-specific publishers for uploading artifacts.

Publisher (Abstract)

Abstract base class for all publishers.
Source: packages/electron-publish/src/publisher.ts:13

GitHubPublisher

Publishes to GitHub Releases.
Configuration:

S3Publisher

Publishes to Amazon S3.
Configuration:

SpacesPublisher

Publishes to DigitalOcean Spaces.
Configuration:

GitlabPublisher

Publishes to GitLab Releases.
Configuration:

BitbucketPublisher

Publishes to Bitbucket Downloads.
Configuration:

KeygenPublisher

Publishes to Keygen.
Configuration:

SnapStorePublisher

Publishes to Snap Store.
Configuration:

HttpPublisher

Publishes to a generic HTTP endpoint.
Configuration:

Utility Functions

getCiTag()

Gets the Git tag from CI environment variables.
Returns: Tag name from CI environment, or null if not in a tagged build. Supported CI systems:
  • Travis CI (TRAVIS_TAG)
  • AppVeyor (APPVEYOR_REPO_TAG_NAME)
  • CircleCI (CIRCLE_TAG)
  • GitLab CI (CI_COMMIT_TAG)
  • GitHub Actions (GITHUB_REF_NAME when GITHUB_REF_TYPE is β€œtag”)
  • Bitrise (BITRISE_GIT_TAG)
  • Bitbucket (BITBUCKET_TAG)
Example:

Example: Custom Publisher

Configuration in electron-builder

Publish configuration is specified in your build configuration:
Or from command line:

Environment Variables

Publishers use environment variables for authentication:
  • GitHub: GH_TOKEN or GITHUB_TOKEN
  • GitLab: GITLAB_TOKEN
  • Bitbucket: BITBUCKET_TOKEN
  • S3: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  • Spaces: DO_TOKEN
  • Keygen: KEYGEN_TOKEN
  • Snap Store: SNAPCRAFT_STORE_CREDENTIALS

Import Examples

CommonJS

ES Modules / TypeScript

See Also