1
1
import BluebirdPromise from "bluebird-lst"
2
2
import { createHash } from "crypto"
3
- import { Platform , PlatformSpecificBuildOptions , Target } from "electron-builder-core"
3
+ import { Arch , Platform , PlatformSpecificBuildOptions , Target } from "electron-builder-core"
4
4
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
5
5
import { BintrayOptions , GenericServerOptions , GithubOptions , githubUrl , PublishConfiguration , PublishProvider , S3Options , s3Url , UpdateInfo , VersionInfo } from "electron-builder-http/out/publishOptions"
6
6
import { asArray , debug , isEmptyOrSpaces , isPullRequest , safeStringifyJson } from "electron-builder-util"
@@ -73,7 +73,7 @@ export class PublishManager implements PublishContext {
73
73
return
74
74
}
75
75
76
- const publishConfigs = await getPublishConfigsForUpdateInfo ( packager , await getPublishConfigs ( packager , null ) )
76
+ const publishConfigs = await getPublishConfigsForUpdateInfo ( packager , await getPublishConfigs ( packager , null , event . arch ) , event . arch )
77
77
if ( publishConfigs == null || publishConfigs . length === 0 ) {
78
78
return
79
79
}
@@ -96,7 +96,7 @@ export class PublishManager implements PublishContext {
96
96
private async artifactCreated ( event : ArtifactCreated ) {
97
97
const packager = event . packager
98
98
const target = event . target
99
- const publishConfigs = event . publishConfig == null ? await getPublishConfigs ( packager , target == null ? null : target . options ) : [ event . publishConfig ]
99
+ const publishConfigs = event . publishConfig == null ? await getPublishConfigs ( packager , target == null ? null : target . options , event . arch ) : [ event . publishConfig ]
100
100
101
101
const eventFile = event . file
102
102
if ( publishConfigs == null ) {
@@ -184,7 +184,7 @@ export class PublishManager implements PublishContext {
184
184
}
185
185
}
186
186
187
- export async function getPublishConfigsForUpdateInfo ( packager : PlatformPackager < any > , publishConfigs : Array < PublishConfiguration > | null ) : Promise < Array < PublishConfiguration > | null > {
187
+ export async function getPublishConfigsForUpdateInfo ( packager : PlatformPackager < any > , publishConfigs : Array < PublishConfiguration > | null , arch : Arch | null ) : Promise < Array < PublishConfiguration > | null > {
188
188
if ( publishConfigs === null ) {
189
189
return null
190
190
}
@@ -195,7 +195,7 @@ export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<
195
195
// default publish config is github, file should be generated regardless of publish state (user can test installer locally or manage the release process manually)
196
196
const repositoryInfo = await packager . info . repositoryInfo
197
197
if ( repositoryInfo != null && repositoryInfo . type === "github" ) {
198
- const resolvedPublishConfig = await getResolvedPublishConfig ( packager , { provider : repositoryInfo . type } , false )
198
+ const resolvedPublishConfig = await getResolvedPublishConfig ( packager , { provider : repositoryInfo . type } , arch , false )
199
199
if ( resolvedPublishConfig != null ) {
200
200
return [ resolvedPublishConfig ]
201
201
}
@@ -206,7 +206,7 @@ export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<
206
206
207
207
async function writeUpdateInfo ( event : ArtifactCreated , _publishConfigs : Array < PublishConfiguration > ) {
208
208
const packager = event . packager
209
- const publishConfigs = await getPublishConfigsForUpdateInfo ( packager , _publishConfigs )
209
+ const publishConfigs = await getPublishConfigsForUpdateInfo ( packager , _publishConfigs , event . arch )
210
210
if ( publishConfigs == null || publishConfigs . length === 0 ) {
211
211
return
212
212
}
@@ -236,6 +236,7 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
236
236
237
237
packager . info . dispatchArtifactCreated ( {
238
238
file : updateInfoFile ,
239
+ arch : null ,
239
240
packager : packager ,
240
241
target : null ,
241
242
publishConfig : publishConfig ,
@@ -273,13 +274,15 @@ async function writeWindowsUpdateInfo(event: ArtifactCreated, version: string, o
273
274
packager : packager ,
274
275
target : null ,
275
276
publishConfig : githubPublishConfig ,
277
+ arch : null ,
276
278
} )
277
279
}
278
280
279
281
const genericPublishConfig = publishConfigs . find ( it => it . provider === "generic" || it . provider === "s3" )
280
282
if ( genericPublishConfig != null ) {
281
283
packager . info . dispatchArtifactCreated ( {
282
284
file : updateInfoFile ,
285
+ arch : null ,
283
286
packager : packager ,
284
287
target : null ,
285
288
publishConfig : genericPublishConfig ,
@@ -347,7 +350,7 @@ export function computeDownloadUrl(publishConfig: PublishConfiguration, fileName
347
350
return `${ baseUrl } /${ encodeURI ( fileName ) } `
348
351
}
349
352
350
- export async function getPublishConfigs ( packager : PlatformPackager < any > , targetSpecificOptions : PlatformSpecificBuildOptions | null | undefined ) : Promise < Array < PublishConfiguration > | null > {
353
+ export async function getPublishConfigs ( packager : PlatformPackager < any > , targetSpecificOptions : PlatformSpecificBuildOptions | null | undefined , arch : Arch | null ) : Promise < Array < PublishConfiguration > | null > {
351
354
let publishers
352
355
353
356
// check build.nsis (target)
@@ -385,7 +388,7 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS
385
388
386
389
if ( serviceName != null ) {
387
390
debug ( `Detect ${ serviceName } as publish provider` )
388
- return [ ( await getResolvedPublishConfig ( packager , { provider : serviceName } ) ) ! ]
391
+ return [ ( await getResolvedPublishConfig ( packager , { provider : serviceName } , arch ) ) ! ]
389
392
}
390
393
}
391
394
@@ -394,7 +397,7 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS
394
397
}
395
398
396
399
debug ( `Explicit publish provider: ${ safeStringifyJson ( publishers ) } ` )
397
- return await ( < Promise < Array < PublishConfiguration > > > BluebirdPromise . map ( asArray ( publishers ) , it => getResolvedPublishConfig ( packager , typeof it === "string" ? { provider : it } : it ) ) )
400
+ return await ( < Promise < Array < PublishConfiguration > > > BluebirdPromise . map ( asArray ( publishers ) , it => getResolvedPublishConfig ( packager , typeof it === "string" ? { provider : it } : it , arch ) ) )
398
401
}
399
402
400
403
function sha256 ( file : string ) {
@@ -423,22 +426,21 @@ function getCiTag() {
423
426
return tag != null && tag . length > 0 ? tag : null
424
427
}
425
428
426
- function expandPublishConfig ( options : any , packager : PlatformPackager < any > ) : void {
429
+ function expandPublishConfig ( options : any , packager : PlatformPackager < any > , arch : Arch | null ) : void {
427
430
for ( const name of Object . keys ( options ) ) {
428
431
const value = options [ name ]
429
432
if ( typeof value === "string" ) {
430
- const expanded = packager . expandMacro ( value , null )
433
+ const expanded = packager . expandMacro ( value , arch )
431
434
if ( expanded !== value ) {
432
435
options [ name ] = expanded
433
436
}
434
437
}
435
438
}
436
439
}
437
-
438
440
439
- async function getResolvedPublishConfig ( packager : PlatformPackager < any > , options : PublishConfiguration , errorIfCannot : boolean = true ) : Promise < PublishConfiguration | null > {
441
+ async function getResolvedPublishConfig ( packager : PlatformPackager < any > , options : PublishConfiguration , arch : Arch | null , errorIfCannot : boolean = true ) : Promise < PublishConfiguration | null > {
440
442
options = Object . assign ( Object . create ( null ) , options )
441
- expandPublishConfig ( options , packager )
443
+ expandPublishConfig ( options , packager , arch )
442
444
443
445
const provider = options . provider
444
446
if ( provider === "generic" ) {
0 commit comments