Skip to content

Commit

Permalink
feat(deployment): Do not upload auto-update files for the second conf…
Browse files Browse the repository at this point in the history
…igured provider

Close #2697
  • Loading branch information
develar committed Mar 18, 2018
1 parent 7a9d220 commit cec3069
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export interface PublishConfiguration {
* @private
*/
readonly publisherName?: Array<string> | null

/**
* Whether to publish auto update info files.
*
* 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.
*
* @default true
*/
readonly publishAutoUpdate?: boolean
}

/**
Expand Down
13 changes: 11 additions & 2 deletions packages/electron-builder-lib/src/publish/updateInfoBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BluebirdPromise from "bluebird-lst"
import { Arch, hashFile, safeStringifyJson, serializeToYaml } from "builder-util"
import { Arch, hashFile, safeStringifyJson, serializeToYaml, log } from "builder-util"
import { GenericServerOptions, GithubOptions, PublishConfiguration, UpdateInfo, WindowsUpdateInfo } from "builder-util-runtime"
import { outputFile, outputJson, readFile } from "fs-extra-p"
import { Lazy } from "lazy-val"
Expand Down Expand Up @@ -184,6 +184,15 @@ export async function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfo

const releaseDate = new Date().toISOString()
await BluebirdPromise.map(updateChannelFileToInfo.values(), async task => {
const publishConfig = task.publishConfiguration
if (publishConfig.publishAutoUpdate === false) {
log.debug({
provider: publishConfig.provider,
reason: "publishAutoUpdate is set to false"
}, "auto update metadata file not published")
return
}

task.info.releaseDate = releaseDate
const fileContent = Buffer.from(serializeToYaml(task.info))
await outputFile(task.file, fileContent)
Expand All @@ -193,7 +202,7 @@ export async function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfo
arch: null,
packager: task.packager,
target: null,
publishConfig: task.publishConfiguration,
publishConfig,
})
}, {concurrency: 4})
}
Expand Down
33 changes: 33 additions & 0 deletions test/out/__snapshots__/PublishManagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,39 @@ Object {
}
`;

exports[`github and spaces (publishAutoUpdate) 1`] = `
Object {
"linux": Array [
Object {
"arch": "x64",
"file": "TestApp-1.1.0-x86_64.AppImage",
"updateInfo": Object {
"blockMapSize": "@blockMapSize",
"sha512": "@sha512",
"size": "@size",
},
},
Object {
"file": "latest-linux.yml",
"fileContent": Object {
"files": Array [
Object {
"blockMapSize": "@blockMapSize",
"sha512": "@sha512",
"size": "@size",
"url": "TestApp-1.1.0-x86_64.AppImage",
},
],
"path": "TestApp-1.1.0-x86_64.AppImage",
"releaseDate": "@releaseDate",
"sha512": "@sha512",
"version": "1.1.0",
},
},
],
}
`;

exports[`mac artifactName 1`] = `
Object {
"mac": Array [
Expand Down
21 changes: 21 additions & 0 deletions test/src/PublishManagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ test.ifDevOrLinuxCi("generic, github and spaces", app({
},
}))

test.ifDevOrLinuxCi("github and spaces (publishAutoUpdate)", app({
targets: Platform.LINUX.createTarget("AppImage"),
config: {
mac: {
electronUpdaterCompatibility: ">=2.16",
},
publish: [
{
provider: "github",
repo: "foo/foo"
},
{
provider: "spaces",
name: "mySpaceName",
region: "nyc3",
publishAutoUpdate: false
},
]
},
}))

test.ifDevOrLinuxCi.ifAll("mac artifactName ", app({
targets: Platform.MAC.createTarget("zip"),
config: {
Expand Down

0 comments on commit cec3069

Please sign in to comment.