Skip to content

Commit 7d8e097

Browse files
committed
feat: PUBLISH_FOR_PULL_REQUEST
1 parent e4e5cc7 commit 7d8e097

File tree

7 files changed

+114
-83
lines changed

7 files changed

+114
-83
lines changed

docs/api/electron-builder-util.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* [electron-builder-util/out/binDownload](#module_electron-builder-util/out/binDownload)
2727
* [`.getBin(name, dirName, url, sha2)`](#module_electron-builder-util/out/binDownload.getBin) ⇒ <code>Promise&lt;string&gt;</code>
2828
* [`.getBinFromBintray(name, version, sha2)`](#module_electron-builder-util/out/binDownload.getBinFromBintray) ⇒ <code>Promise&lt;string&gt;</code>
29+
* [`.getBinFromGithub(name, version, sha2)`](#module_electron-builder-util/out/binDownload.getBinFromGithub) ⇒ <code>Promise&lt;string&gt;</code>
2930

3031
<a name="module_electron-builder-util/out/binDownload.getBin"></a>
3132

@@ -50,6 +51,17 @@
5051
| version | <code>string</code> |
5152
| sha2 | <code>string</code> |
5253

54+
<a name="module_electron-builder-util/out/binDownload.getBinFromGithub"></a>
55+
56+
### `electron-builder-util/out/binDownload.getBinFromGithub(name, version, sha2)` ⇒ <code>Promise&lt;string&gt;</code>
57+
**Kind**: method of [<code>electron-builder-util/out/binDownload</code>](#module_electron-builder-util/out/binDownload)
58+
59+
| Param | Type |
60+
| --- | --- |
61+
| name | <code>string</code> |
62+
| version | <code>string</code> |
63+
| sha2 | <code>string</code> |
64+
5365
<a name="module_electron-builder-util/out/deepAssign"></a>
5466

5567
## electron-builder-util/out/deepAssign

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"///": "all dependencies for all packages (hoisted)",
2929
"dependencies": {
3030
"7zip-bin": "^2.0.4",
31-
"ajv": "^5.1.4",
32-
"ajv-keywords": "^2.0.0",
31+
"ajv": "^5.1.5",
32+
"ajv-keywords": "^2.1.0",
3333
"archiver": "^1.3.0",
3434
"aws-sdk": "^2.58.0",
3535
"bluebird-lst": "^1.0.2",
@@ -84,7 +84,7 @@
8484
"develar-typescript-json-schema": "0.11.0",
8585
"env-paths": "^1.0.0",
8686
"globby": "^6.1.0",
87-
"jest-cli": "^20.0.3",
87+
"jest-cli": "^20.0.4",
8888
"jest-environment-node-debug": "^2.0.0",
8989
"jest-junit": "^1.5.1",
9090
"jsdoc-to-markdown": "^3.0.0",

packages/electron-builder/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"homepage": "https://github.com/electron-userland/electron-builder",
4646
"dependencies": {
4747
"7zip-bin": "^2.0.4",
48-
"ajv": "^5.1.4",
49-
"ajv-keywords": "^2.0.0",
48+
"ajv": "^5.1.5",
49+
"ajv-keywords": "^2.1.0",
5050
"bluebird-lst": "^1.0.2",
5151
"chalk": "^1.1.3",
5252
"chromium-pickle-js": "^0.2.0",

packages/electron-builder/src/macPackager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
125125
}
126126
else {
127127
// https://github.com/electron-userland/electron-builder/issues/1524
128-
log("Current build is a part of pull request, code signing will be skipped." +
128+
warn("Current build is a part of pull request, code signing will be skipped." +
129129
"\nSet env CSC_FOR_PULL_REQUEST to true to force code signing." +
130130
`\n${buildForPrWarning}`)
131131
return

packages/electron-builder/src/publish/PublishManager.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import { ArtifactCreated, BuildInfo } from "../packagerApi"
2222
import { PlatformPackager } from "../platformPackager"
2323
import { WinPackager } from "../winPackager"
2424

25+
const publishForPrWarning = "There are serious security concerns with PUBLISH_FOR_PULL_REQUEST=true (see the CircleCI documentation (https://circleci.com/docs/1.0/fork-pr-builds/) for details)" +
26+
"\nIf you have SSH keys, sensitive env vars or AWS credentials stored in your project settings and untrusted forks can make pull requests against your repo, then this option isn't for you."
27+
2528
export class PublishManager implements PublishContext {
2629
private readonly nameToPublisher = new Map<string, Publisher | null>()
2730

@@ -33,7 +36,12 @@ export class PublishManager implements PublishContext {
3336
readonly progress = (<TtyWriteStream>process.stdout).isTTY ? new MultiProgress() : null
3437

3538
constructor(packager: Packager, private readonly publishOptions: PublishOptions, readonly cancellationToken: CancellationToken) {
36-
if (!isPullRequest()) {
39+
const forcePublishForPr = process.env.PUBLISH_FOR_PULL_REQUEST === "true"
40+
if (!isPullRequest() || forcePublishForPr) {
41+
if (forcePublishForPr) {
42+
warn(publishForPrWarning)
43+
}
44+
3745
if (publishOptions.publish === undefined) {
3846
if (process.env.npm_lifecycle_event === "release") {
3947
publishOptions.publish = "always"
@@ -56,7 +64,9 @@ export class PublishManager implements PublishContext {
5664
}
5765
}
5866
else if (publishOptions.publish !== "never") {
59-
log("Current build is a part of pull request, publishing will be skipped")
67+
log("Current build is a part of pull request, publishing will be skipped" +
68+
"\nSet env PUBLISH_FOR_PULL_REQUEST to true to force code signing." +
69+
`\n${publishForPrWarning}`)
6070
}
6171

6272
packager.addAfterPackHandler(async event => {

test/src/windows/oneClickInstallerTest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ test("one-click", app({
3131

3232
test.ifAll("multi language license", app({
3333
targets: Platform.WINDOWS.createTarget("nsis"),
34+
config: {
35+
publish: null,
36+
},
3437
}, {
3538
projectDirCreated: projectDir => {
3639
return BluebirdPromise.all([
@@ -120,6 +123,7 @@ test.ifAll("menuCategory", app({
120123
productName: "Test Menu Category"
121124
},
122125
config: {
126+
publish: null,
123127
nsis: {
124128
oneClick: false,
125129
menuCategory: true,
@@ -142,6 +146,7 @@ test.ifAll("string menuCategory", app({
142146
productName: "Test Menu Category"
143147
},
144148
config: {
149+
publish: null,
145150
nsis: {
146151
oneClick: false,
147152
menuCategory: "Foo/Bar",

0 commit comments

Comments
 (0)