Electron Docs
The publish key contains a set of options instructing electron-builder on how it should publish artifacts and build update info files for auto update.
String | Object | Array<Object | String>
where Object
it is BintrayOptions, GenericServerOptions, GitHub, S3Options or SpacesOptions. Order is important — 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.
If GH_TOKEN
is defined — defaults to [{provider: "github"}]
.
If BT_TOKEN
is defined and GH_TOKEN
is not — defaults to [{provider: "bintray"}]
.
Travis and AppVeyor support publishing artifacts. But it requires additional configuration for each CI and you need to configure what to publish. electron-builder
makes publishing dead simple.
You can publish to multiple providers. For example, to publish Windows artifacts to both GitHub and Bintray (order is important — first item will be used as a default auto-update server, so, in this example app will use github as auto-update provider):
"win": {
"publish": ["github", "bintray"]
}
How do Publish
Excerpt from CLI Usage of electron-builder
command:
Publishing:
--publish, -p [choices: "onTag", "onTagOrDraft", "always", "never"]
CLI --publish
option values:
Value | Description |
---|---|
onTag | on tag push only |
onTagOrDraft | on tag push or if draft release exists |
always | always publish |
never | never publish |
But please consider using automatic rules instead of explicitly specifying publish
:
If CI server detected, —
onTagOrDraft
.If CI server reports that tag was pushed, —
onTag
.Release will be drafted (if doesn't already exist) and artifacts published only if tag was pushed.
If npm script named
release
, —always
.
Add to scripts
in the development package.json
: `
json "release": "build" `
and if you run yarn release
, a release will be drafted (if doesn't already exist) and artifacts published.
Recommended GitHub Releases Workflow
- Draft a new release. Set the "Tag version" to the value of
version
in your applicationpackage.json
, and prefix it withv
. "Release title" can be anything you want.
For example, if your application package.json
version is 1.0
, your draft's "Tag version" would be v1.0
.
- 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.
The benefit of this workflow is that it allows you to always have the latest artifacts, and the release can be published once it is ready.
Continuous Deployment Workflow on Amazon S3 and other non-GitHub
This example workflow is modelled on how releases are handled in maven (it is an example of one of many possible workflows, you are not forced to follow it).
- 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.json
to1.9.0-snapshot
(or1.9.0-master
or whatever you want your development channel to be named). This will publish a file namedsnapshot.yml
and a build namedsomething-snapshot.exe
(and corresponding for mac) to S3. - When you are ready to deploy, simply change you package version to
1.9.0
and push. This will then produce alatest.yml
andsomething.exe
on 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 and Bintray Package
Detected automatically using:
- repository in the application or development
package.json
, - if not set, env
TRAVIS_REPO_SLUG
- or
APPVEYOR_ACCOUNT_NAME
/APPVEYOR_PROJECT_NAME
- or
CIRCLE_PROJECT_USERNAME
/CIRCLE_PROJECT_REPONAME
,
- if no env, from
.git/config
origin url.
BintrayOptions
Bintray options. Requires an API key. An API key can be obtained from the user profile page ("Edit Your Profile" -> API Key). Define BT_TOKEN
environment variable.
provider
"bintray" - The provider. Must bebintray
.package
String - The Bintray package name.repo
=generic
String - The Bintray repository name.owner
String - The owner.component
String - The Bintray component (Debian only).distribution
=stable
String - The Bintray distribution (Debian only).user
String - The Bintray user account. Used in cases where the owner is an organization.token
String
GenericServerOptions
Generic (any HTTP(S) server) options.
provider
"generic" - The provider. Must begeneric
.url
String - The base url. e.g.https://bucket_name.s3.amazonaws.com
. You can use${os}
(expanded tomac
,linux
orwin
according to target platform) and${arch}
macros.channel
=latest
String - The channel.
GithubOptions
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. Define GH_TOKEN
environment variable.
provider
"github" - The provider. Must begithub
.repo
String - The repository name. Detected automatically.owner
String - The owner.vPrefixedTagName
=true
Boolean - Whether to usev
-prefixed tag name.host
=github.com
String - The host (including the port if need).protocol
=https
"https" | "http" - The protocol. GitHub Publisher supports onlyhttps
.token
String - The access token to support auto-update from private github repositories. Never specify it in the configuration files. Only for setFeedURL.private
Boolean - Whether to use private github auto-update provider ifGH_TOKEN
environment variable is defined. See Private GitHub Update Repo.releaseType
=draft
"draft" | "prerelease" | "release" - The type of release. By defaultdraft
release will be created.Also you can set release type using environment variable. If
EP_DRAFT
is set totrue
—draft
, ifEP_PRELEASE
is set totrue
—prerelease
.
S3Options
Amazon S3 options.
To use Amazon S3 please add electron-publisher-s3
dependency to devDependencies
(yarn add electron-publisher-s3 --dev
).
AWS credentials are required, please see getting your credentials. Define AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables. Or in the ~/.aws/credentials.
Example configuration:
"publish": {
"provider": "s3",
"bucket": "bucket-name"
}
{% include "/generated/s3-options.md" %}
{% include "/generated/spaces-options.md" %}
相关npm包集合
- electron-packager
- electron-builder
- electron-updater
- electron-download
- electron-apps
- electron-to-chromium
- awesome-electron
- electron-debug
- electron-rebuild