1
1
require ( 'dotenv' ) . config ( ) ;
2
2
const { notarize } = require ( '@electron/notarize' ) ;
3
3
4
+ async function retryNotarize ( options , retries = 5 , delay = 5000 ) {
5
+ for ( let i = 0 ; i < retries ; i ++ ) {
6
+ try {
7
+ console . log ( `Attempt ${ i + 1 } to notarize...` ) ;
8
+ await notarize ( options ) ;
9
+ console . log ( 'Notarization successful' ) ;
10
+ return ;
11
+ } catch ( error ) {
12
+ console . error ( `Notarization attempt ${ i + 1 } failed:` , error ) ;
13
+ if ( i < retries - 1 ) {
14
+ console . log ( `Retrying in ${ delay / 1000 } seconds...` ) ;
15
+ await new Promise ( resolve => setTimeout ( resolve , delay ) ) ;
16
+ delay *= 2 ; // Increase delay for the next retry
17
+ } else {
18
+ console . log ( 'All notarization attempts failed...' ) ;
19
+ // Add any necessary teardown logic here
20
+ throw error ;
21
+ }
22
+ }
23
+ }
24
+ }
25
+
4
26
exports . default = async function notarizing ( context ) {
5
27
const { electronPlatformName, appOutDir } = context ;
6
28
if ( electronPlatformName !== 'darwin' ) {
@@ -9,8 +31,8 @@ exports.default = async function notarizing(context) {
9
31
10
32
const appName = context . packager . appInfo . productFilename ;
11
33
12
- console . log ( 'Starting custom notarization process...' )
13
- return await notarize ( {
34
+ console . log ( 'Starting custom notarization process...' ) ;
35
+ await retryNotarize ( {
14
36
appPath : `${ appOutDir } /${ appName } .app` ,
15
37
appleId : process . env . APPLE_ID ,
16
38
appleIdPassword : process . env . APPLE_ID_APP_PASS ,
0 commit comments