Electron Forge
  • Getting Started
  • Importing an Existing Project
  • CLI
  • Core Concepts
    • Why Electron Forge?
    • Build Lifecycle
  • Configuration
    • Configuration Overview
    • TypeScript Setup
    • Plugins
      • Webpack Plugin
      • Vite Plugin
      • Electronegativity Plugin
      • Auto Unpack Native Modules Plugin
      • Local Electron Plugin
      • Fuses Plugin
    • Makers
      • AppX
      • deb
      • DMG
      • Flatpak
      • pkg
      • RPM
      • Snapcraft
      • Squirrel.Windows
      • WiX MSI
      • ZIP
    • Publishers
      • Bitbucket
      • Electron Release Server
      • GitHub
      • Google Cloud Storage
      • Nucleus
      • S3
      • Snapcraft
    • Hooks
  • Built-in Templates
    • Webpack
    • Webpack + Typescript
    • Vite
    • Vite + TypeScript
  • Guides
    • Code Signing
      • Signing a Windows app
      • Signing a macOS app
    • Custom App Icons
    • Framework Integration
      • React
      • React with TypeScript
      • Vue 3
    • Developing with WSL
  • Advanced
    • Auto Update
    • Debugging
    • Extending Electron Forge
      • Writing Plugins
      • Writing Templates
      • Writing Makers
      • Writing Publishers
    • API Docs
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Advanced
  2. Extending Electron Forge

Writing Publishers

PreviousWriting Makers

Last updated 1 year ago

Was this helpful?

An Electron Forge Publisher has to export a single class that extends the base publisher. The base plugin can be depended on by installing@electron-forge/publisher-base.

Check out the interface of for more advanced API details.

The publisher must implement one method:

publish(options: PublisherOptions): Promise<void>

Publishers must implement this method to publish the artifacts returned from make calls. If any errors occur you must throw them, failing silently or simply logging will not propagate issues up to Forge.

Please note for a given version, publish will be called multiple times, once for each set of "platform" and "arch". This means if you are publishing darwin and win32 artifacts to somewhere like GitHub on the first publish call, you will have to create the version on GitHub and the second call will just be appending files to the existing version. Your publish implementation will not be aware that another call is coming, however it must just be able to handle this case.

The config for the publisher will be available on this.config.

The options object is documented in .

export default class MyPublisher extends PublisherBase {
  async publish (opts) {
    for (const result of opts.makeResults) {
      await createVersionIfNotExists();
      await uploadDistributable(result);
    }
  }
}
PublisherBase
PublisherOptions