Skip to content

Commit a945321

Browse files
authored
feat: adding Bitbucket publisher and autoupdater (#6228)
1 parent 369f1fa commit a945321

25 files changed

+534
-94
lines changed

.changeset/shiny-colts-behave.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"app-builder-lib": minor
3+
"builder-util-runtime": minor
4+
"builder-util": minor
5+
"electron-publish": minor
6+
"electron-updater": minor
7+
---
8+
9+
feat: adding Bitbucket publisher and autoupdater

docs/api/electron-builder.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ return path.join(target.outDir, <code>__${target.name}-${getArtifactArchName(arc
17091709
<tbody>
17101710
<tr>
17111711
<td>options</td>
1712-
<td><code><a href="/configuration/publish#publishconfiguration">PublishConfiguration</a></code> | <code>String</code> | <code><a href="/configuration/publish#githuboptions">GithubOptions</a></code> | <code><a href="/configuration/publish#s3options">S3Options</a></code> | <code><a href="/configuration/publish#spacesoptions">SpacesOptions</a></code> | <code><a href="/configuration/publish#genericserveroptions">GenericServerOptions</a></code> | <code><a href="/configuration/publish#bintrayoptions">BintrayOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.CustomPublishOptions</code> | <code>module:builder-util-runtime/out/publishOptions.KeygenOptions</code> | <code><a href="/configuration/publish#snapstoreoptions">SnapStoreOptions</a></code> | <code>String</code></td>
1712+
<td><code><a href="/configuration/publish#publishconfiguration">PublishConfiguration</a></code> | <code>String</code> | <code><a href="/configuration/publish#githuboptions">GithubOptions</a></code> | <code><a href="/configuration/publish#s3options">S3Options</a></code> | <code><a href="/configuration/publish#spacesoptions">SpacesOptions</a></code> | <code><a href="/configuration/publish#genericserveroptions">GenericServerOptions</a></code> | <code><a href="/configuration/publish#bintrayoptions">BintrayOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.CustomPublishOptions</code> | <code>module:builder-util-runtime/out/publishOptions.KeygenOptions</code> | <code><a href="/configuration/publish#snapstoreoptions">SnapStoreOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.BitbucketOptions</code> | <code>String</code></td>
17131713
<td>If you want to override configuration in the <code>app-update.yml</code>.</td>
17141714
</tr>
17151715
</tbody>
@@ -1834,7 +1834,7 @@ This is different from the normal quit event sequence.</p>
18341834
<tbody>
18351835
<tr>
18361836
<td>options</td>
1837-
<td><code><a href="/configuration/publish#publishconfiguration">PublishConfiguration</a></code> | <code>String</code> | <code><a href="/configuration/publish#githuboptions">GithubOptions</a></code> | <code><a href="/configuration/publish#s3options">S3Options</a></code> | <code><a href="/configuration/publish#spacesoptions">SpacesOptions</a></code> | <code><a href="/configuration/publish#genericserveroptions">GenericServerOptions</a></code> | <code><a href="/configuration/publish#bintrayoptions">BintrayOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.CustomPublishOptions</code> | <code>module:builder-util-runtime/out/publishOptions.KeygenOptions</code> | <code><a href="/configuration/publish#snapstoreoptions">SnapStoreOptions</a></code> | <code>String</code></td>
1837+
<td><code><a href="/configuration/publish#publishconfiguration">PublishConfiguration</a></code> | <code>String</code> | <code><a href="/configuration/publish#githuboptions">GithubOptions</a></code> | <code><a href="/configuration/publish#s3options">S3Options</a></code> | <code><a href="/configuration/publish#spacesoptions">SpacesOptions</a></code> | <code><a href="/configuration/publish#genericserveroptions">GenericServerOptions</a></code> | <code><a href="/configuration/publish#bintrayoptions">BintrayOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.CustomPublishOptions</code> | <code>module:builder-util-runtime/out/publishOptions.KeygenOptions</code> | <code><a href="/configuration/publish#snapstoreoptions">SnapStoreOptions</a></code> | <code>module:builder-util-runtime/out/publishOptions.BitbucketOptions</code> | <code>String</code></td>
18381838
<td>If you want to override configuration in the <code>app-update.yml</code>.</td>
18391839
</tr>
18401840
</tbody>

docs/configuration/publish.md

+88-29
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ If `KEYGEN_TOKEN` is defined and `GH_TOKEN` or `GITHUB_TOKEN` is not — default
1212
!!! info "Snap store"
1313
`snap` target by default publishes to snap store (the app store for Linux). To force publishing to another providers, explicitly specify publish configuration for `snap`.
1414

15-
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):
15+
You can publish to multiple providers. For example, to publish Windows artifacts to both GitHub and Bitbucket (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):
1616

17-
```json tab="package.json"
17+
```json
1818
{
1919
"build": {
2020
"win": {
21-
"publish": ["github", "bintray"]
21+
"publish": ["github", "bitbucket"]
2222
}
2323
}
2424
}
2525
```
2626

27-
```yaml tab="electron-builder.yaml"
27+
```yaml
2828
win:
2929
publish:
3030
- github
31-
- bintray
31+
- bitbucket
3232
```
3333
3434
You can also configure publishing using CLI arguments, for example, to force publishing snap not to Snap Store, but to GitHub: `-c.snap.publish=github`
@@ -66,7 +66,7 @@ But please consider using automatic rules instead of explicitly specifying `publ
6666

6767
Add to `scripts` in the development `package.json`:
6868

69-
```json tab="package.json"
69+
```json
7070
"release": "electron-builder"
7171
```
7272

@@ -92,7 +92,7 @@ This example workflow is modelled on how releases are handled in maven (it is an
9292
3. When you are ready to deploy, simply change you package version to `1.9.0` and push. This will then produce a `latest.yml` and `something.exe` on s3. Usually you'll git-tag this version as well (just to keep track of it).
9393
4. Change the version back to a snapshot version right after, i.e. `1.10.0-snapshot`, and commit it.
9494

95-
## GitHub Repository and Bintray Package
95+
## GitHub Repository
9696

9797
Detected automatically using:
9898

@@ -103,6 +103,16 @@ Detected automatically using:
103103
* or `CIRCLE_PROJECT_USERNAME`/`CIRCLE_PROJECT_REPONAME`,
104104
* if no env, from `.git/config` origin url.
105105

106+
## Publishers
107+
**Options Available:**
108+
- GenericServerOptions
109+
- GithubOptions
110+
- SnapStoreOptions
111+
- SpacesOptions
112+
- KeygenOptions
113+
- BitbucketOptions
114+
- S3Options
115+
106116
<!-- do not edit. start of generated block -->
107117
<h2 id="genericserveroptions">GenericServerOptions</h2>
108118
<p>Generic (any HTTP(S) server) options.
@@ -216,27 +226,76 @@ Define <code>KEYGEN_TOKEN</code> environment variable.</p>
216226
<p><code id="KeygenOptions-requestHeaders">requestHeaders</code> module:http.OutgoingHttpHeaders - Any custom request headers</p>
217227
</li>
218228
</ul>
219-
220-
<!-- end of generated block -->
221-
222-
## S3Options
223-
[Amazon S3](https://aws.amazon.com/s3/) options.
224-
225-
AWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).
226-
Define `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html).
227-
Or in the [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html).
228-
229-
Example configuration:
230-
231-
```json tab="package.json"
232-
{
233-
"build":
234-
"publish": {
235-
"provider": "s3",
236-
"bucket": "bucket-name"
237-
}
238-
}
229+
<h2 id="bitbucketoptions">BitbucketOptions</h2>
230+
<p>Bitbucket options.
231+
<a href="https://bitbucket.org/">https://bitbucket.org/</a>
232+
Define <code>BITBUCKET_TOKEN</code> environment variable.</p>
233+
<p>For converting an app password to a usable token, you can utilize this</p>
234+
<pre><code class="hljs language-typescript"><span class="hljs-function"><span class="hljs-title">convertAppPassword</span>(<span class="hljs-params">owner: <span class="hljs-built_in">string</span>, token: <span class="hljs-built_in">string</span></span>)</span> {
235+
<span class="hljs-keyword">const</span> base64encodedData = Buffer.from(<span class="hljs-string">`<span class="hljs-subst">${owner}</span>:<span class="hljs-subst">${token.trim()}</span>`</span>).toString(<span class="hljs-string">&quot;base64&quot;</span>)
236+
<span class="hljs-keyword">return</span> <span class="hljs-string">`Basic <span class="hljs-subst">${base64encodedData}</span>`</span>
239237
}
240-
```
238+
</code></pre>
239+
<ul>
240+
<li><strong><code id="BitbucketOptions-provider">provider</code></strong> “bitbucket” - The provider. Must be <code>bitbucket</code>.</li>
241+
<li><strong><code id="BitbucketOptions-owner">owner</code></strong> String - Repository owner</li>
242+
<li><strong><code id="BitbucketOptions-slug">slug</code></strong> String - Repository slug/name</li>
243+
<li><code id="BitbucketOptions-channel">channel</code> = <code>latest</code> String | “undefined” - The channel.</li>
244+
</ul>
245+
<p>Inherited from <code>PublishConfiguration</code>:</p>
246+
<ul>
247+
<li>
248+
<p><code id="BitbucketOptions-publishAutoUpdate">publishAutoUpdate</code> = <code>true</code> Boolean - Whether to publish auto update info files.</p>
249+
<p>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.</p>
250+
</li>
251+
<li>
252+
<p><code id="BitbucketOptions-requestHeaders">requestHeaders</code> module:http.OutgoingHttpHeaders - Any custom request headers</p>
253+
</li>
254+
</ul>
255+
<h2 id="s3options">S3Options</h2>
256+
<p><a href="https://aws.amazon.com/s3/">Amazon S3</a> options.
257+
AWS credentials are required, please see <a href="http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html">getting your credentials</a>.
258+
Define <code>AWS_ACCESS_KEY_ID</code> and <code>AWS_SECRET_ACCESS_KEY</code> <a href="http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html">environment variables</a>.
259+
Or in the <a href="http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html">~/.aws/credentials</a>.</p>
260+
<p>Example configuration:</p>
261+
<pre><code class="hljs language-json">{
262+
<span class="hljs-attr">&quot;build&quot;</span>:
263+
<span class="hljs-string">&quot;publish&quot;</span>: {
264+
<span class="hljs-attr">&quot;provider&quot;</span>: <span class="hljs-string">&quot;s3&quot;</span>,
265+
<span class="hljs-attr">&quot;bucket&quot;</span>: <span class="hljs-string">&quot;bucket-name&quot;</span>
266+
}
267+
}
268+
}
269+
</code></pre>
270+
<ul>
271+
<li>
272+
<p><strong><code id="S3Options-provider">provider</code></strong> “s3” - The provider. Must be <code>s3</code>.</p>
273+
</li>
274+
<li>
275+
<p><strong><code id="S3Options-bucket">bucket</code></strong> String - The bucket name.</p>
276+
</li>
277+
<li>
278+
<p><code id="S3Options-region">region</code> String | “undefined” - The region. Is determined and set automatically when publishing.</p>
279+
</li>
280+
<li>
281+
<p><code id="S3Options-acl">acl</code> = <code>public-read</code> “private” | “public-read” | “undefined” - The ACL. Set to <code>null</code> to not <a href="https://github.com/electron-userland/electron-builder/issues/1822">add</a>.</p>
282+
<p>Please see <a href="https://github.com/electron-userland/electron-builder/issues/1618#issuecomment-314679128">required permissions for the S3 provider</a>.</p>
283+
</li>
284+
<li>
285+
<p><code id="S3Options-storageClass">storageClass</code> = <code>STANDARD</code> “STANDARD” | “REDUCED_REDUNDANCY” | “STANDARD_IA” | “undefined” - The type of storage to use for the object.</p>
286+
</li>
287+
<li>
288+
<p><code id="S3Options-encryption">encryption</code> “AES256” | “aws:kms” | “undefined” - Server-side encryption algorithm to use for the object.</p>
289+
</li>
290+
<li>
291+
<p><code id="S3Options-endpoint">endpoint</code> String | “undefined” - The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like <code>https://{service}.{region}.amazonaws.com</code>.</p>
292+
</li>
293+
<li>
294+
<p><code id="S3Options-channel">channel</code> = <code>latest</code> String | “undefined” - The update channel.</p>
295+
</li>
296+
<li>
297+
<p><code id="S3Options-path">path</code> = <code>/</code> String | “undefined” - The directory path.</p>
298+
</li>
299+
</ul>
241300

242-
{!generated/s3-options.md!}
301+
<!-- end of generated block -->

docs/generated/DebOptions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ul>
2-
<li><code id="DebOptions-depends">depends</code> Array&lt;String&gt; | “undefined” - Package dependencies. Defaults to <code>[&quot;gconf2&quot;, &quot;gconf-service&quot;, &quot;libnotify4&quot;, &quot;libappindicator1&quot;, &quot;libxtst6&quot;, &quot;libnss3&quot;]</code>. If need to support Debian, <code>libappindicator1</code> should be removed, <a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=895037">deprecated in Debian</a>. If need to support KDE, <code>gconf2</code> and <code>gconf-service</code> should be removed, <a href="https://packages.debian.org/bullseye/gconf2">for GNOME and no longer used by GNOME</a>.</li>
2+
<li><code id="DebOptions-depends">depends</code> Array&lt;String&gt; | “undefined” - Package dependencies. Defaults to <code>[&quot;gconf2&quot;, &quot;gconf-service&quot;, &quot;libnotify4&quot;, &quot;libappindicator1&quot;, &quot;libxtst6&quot;, &quot;libnss3&quot;]</code>. If need to support Debian, <code>libappindicator1</code> should be removed, it is <a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=895037">deprecated in Debian</a>. If need to support KDE, <code>gconf2</code> and <code>gconf-service</code> should be removed as it’s no longer used by GNOME](<a href="https://packages.debian.org/bullseye/gconf2">https://packages.debian.org/bullseye/gconf2</a>).</li>
33
<li><code id="DebOptions-packageCategory">packageCategory</code> String | “undefined” - The <a href="https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Section">package category</a>.</li>
44
<li><code id="DebOptions-priority">priority</code> String | “undefined” - The <a href="https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Priority">Priority</a> attribute.</li>
55
</ul>

docs/generated/bitbucket-options.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<ul>
2+
<li><strong><code id="BitbucketOptions-provider">provider</code></strong> “bitbucket” - The provider. Must be <code>bitbucket</code>.</li>
3+
<li><strong><code id="BitbucketOptions-owner">owner</code></strong> String - Repository owner</li>
4+
<li><strong><code id="BitbucketOptions-slug">slug</code></strong> String - Repository slug/name</li>
5+
<li><code id="BitbucketOptions-channel">channel</code> = <code>latest</code> String | “undefined” - The channel.</li>
6+
</ul>
7+
<p>Inherited from <code>PublishConfiguration</code>:</p>
8+
<ul>
9+
<li>
10+
<p><code id="BitbucketOptions-publishAutoUpdate">publishAutoUpdate</code> = <code>true</code> Boolean - Whether to publish auto update info files.</p>
11+
<p>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.</p>
12+
</li>
13+
<li>
14+
<p><code id="BitbucketOptions-requestHeaders">requestHeaders</code> module:http.OutgoingHttpHeaders - Any custom request headers</p>
15+
</li>
16+
</ul>

docs/generated/s3-options.md

-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
<!-- FILE IS AUTOGENERATED. Please edit S3Options class jsdoc in the packages/builder-util-runtime/src/publishOptions.ts -->
2-
3-
<!-- do not edit. start of generated block -->
41
<ul>
52
<li>
63
<p><strong><code id="S3Options-provider">provider</code></strong> “s3” - The provider. Must be <code>s3</code>.</p>
@@ -31,5 +28,3 @@
3128
<p><code id="S3Options-path">path</code> = <code>/</code> String | “undefined” - The directory path.</p>
3229
</li>
3330
</ul>
34-
35-
<!-- end of generated block -->

docs/generated/snap-store-options.md

-17
This file was deleted.

docs/generated/spaces-options.md

-16
This file was deleted.

packages/app-builder-lib/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"ejs": "^3.1.6",
6161
"electron-osx-sign": "^0.5.0",
6262
"electron-publish": "workspace:*",
63+
"form-data": "^4.0.0",
6364
"fs-extra": "^10.0.0",
6465
"hosted-git-info": "^4.0.2",
6566
"is-ci": "^3.0.0",

0 commit comments

Comments
 (0)