@@ -31,7 +31,7 @@ type SigningConfig = {
3131 remove : string [ ] ;
3232} ;
3333
34- export async function sign ( workDir : string ) : Promise < string > {
34+ export async function sign ( workDir : string ) : Promise < string [ ] > {
3535 const certFingerprint = process . env . CSC_FINGERPRINT ?? '' ;
3636 const appleId = process . env . APPLEID ;
3737 const appleIdPassword = process . env . AC_PASSWORD ;
@@ -125,28 +125,42 @@ export async function sign(workDir: string): Promise<string> {
125125 throw new Error ( message . join ( '\n' ) ) ;
126126 }
127127
128- console . log ( 'Building disk image...' ) ;
128+ console . log ( 'Building disk image and update archive ...' ) ;
129129 const arch = process . env . M1 ? Arch . arm64 : Arch . x64 ;
130130 const productFileName = config . productName ?. replace ( / \s + / g, '.' ) ;
131131 const productArch = process . env . M1 ? 'aarch64' : 'x86_64' ;
132- const artifactName = `${ productFileName } -\${version}.${ productArch } .\${ext}` ;
132+ const artifactName = `${ productFileName } -\${version}-mac.${ productArch } .\${ext}` ;
133+ const formats = [ 'dmg' , 'zip' ] ;
133134
134135 // Build the dmg, explicitly _not_ using an identity; we just signed
135136 // everything as we wanted already.
136137 const results = await build ( {
137- targets : new Map ( [ [ Platform . MAC , new Map ( [ [ arch , [ 'dmg' ] ] ] ) ] ] ) ,
138+ targets : new Map ( [ [ Platform . MAC , new Map ( [ [ arch , formats ] ] ) ] ] ) ,
138139 config : _ . merge < Configuration , Configuration > ( config , { mac : { artifactName, identity : null } } ) ,
139140 prepackaged : appDir ,
140141 } ) ;
141142
142- const dmgFile = results . find ( v => v . endsWith ( '.dmg' ) ) ;
143+ // The .dmg and the .zip have slightly different file names, so we need to
144+ // deal with them separately.
145+
146+ const dmgFile = results . find ( f => f . endsWith ( '.dmg' ) ) ;
147+ const zipFile = results . find ( f => f . endsWith ( '.zip' ) ) ;
143148
144149 if ( ! dmgFile ) {
145- throw new Error ( `Could not find signed disk image` ) ;
150+ throw new Error ( `Could not find build disk image` ) ;
151+ }
152+ if ( ! zipFile ) {
153+ throw new Error ( `Could not find build zip file` ) ;
146154 }
147- await spawnFile ( 'codesign' , [ '--sign' , certFingerprint , '--timestamp' , dmgFile ] , { stdio : 'inherit' } ) ;
148155
149- return dmgFile ;
156+ const dmgRenamedFile = dmgFile . replace ( '-mac.' , '.' ) ;
157+
158+ await fs . promises . rename ( dmgFile , dmgRenamedFile ) ;
159+ await Promise . all ( [ dmgRenamedFile , zipFile ] . map ( ( f ) => {
160+ return spawnFile ( 'codesign' , [ '--sign' , certFingerprint , '--timestamp' , f ] , { stdio : 'inherit' } ) ;
161+ } ) ) ;
162+
163+ return Object . values ( [ dmgRenamedFile , zipFile ] ) ;
150164}
151165
152166/**
0 commit comments