File tree Expand file tree Collapse file tree 7 files changed +86
-3
lines changed Expand file tree Collapse file tree 7 files changed +86
-3
lines changed Original file line number Diff line number Diff line change 4
4
<dict >
5
5
<key >com.apple.security.app-sandbox </key >
6
6
<true />
7
+ <key >com.apple.security.cs.allow-unsigned-executable-memory </key >
8
+ <true />
7
9
<key >com.apple.security.inherit </key >
8
10
<true />
9
11
</dict >
Original file line number Diff line number Diff line change 4
4
<dict >
5
5
<key >com.apple.security.app-sandbox </key >
6
6
<true />
7
+ <key >com.apple.security.cs.allow-unsigned-executable-memory </key >
8
+ <true />
7
9
<key >com.apple.security.device.audio-input </key >
8
10
<true />
9
11
<key >com.apple.security.device.camera </key >
Original file line number Diff line number Diff line change @@ -3,8 +3,10 @@ directories:
3
3
output : dist
4
4
appId : edu.mit.scratch.scratch-desktop
5
5
productName : " Scratch Desktop"
6
+ afterSign : " scripts/afterSign.js"
6
7
mac :
7
8
category : public.app-category.education
9
+ hardenedRuntime : true
8
10
icon : buildResources/ScratchDesktop.icns
9
11
provisioningProfile : embedded.provisionprofile
10
12
target :
Original file line number Diff line number Diff line change 38
38
"electron" : " ^6.1.7" ,
39
39
"electron-builder" : " ^22.2.0" ,
40
40
"electron-devtools-installer" : " ^2.2.4" ,
41
+ "electron-notarize" : " ^0.2.1" ,
41
42
"electron-store" : " ^3.3.0" ,
42
43
"electron-webpack" : " ^2.7.4" ,
43
44
"eslint" : " ^5.16.0" ,
Original file line number Diff line number Diff line change
1
+ const { notarize} = require ( 'electron-notarize' ) ;
2
+
3
+ const notarizeMacBuild = async function ( context ) {
4
+ // keep this in sync with appId in the electron-builder config
5
+ const appId = 'edu.mit.scratch.scratch-desktop' ;
6
+
7
+ if ( ! process . env . AC_USERNAME ) {
8
+ throw new Error (
9
+ 'Notarizing the macOS build requires an Apple ID.\n' +
10
+ 'Please set the environment variable AC_USERNAME.\n' +
11
+ 'Make sure your keychain has an item for "Application Loader: [email protected] "'
12
+ ) ;
13
+ }
14
+
15
+ const appleId = process . env . AC_USERNAME ;
16
+ const appleIdKeychainItem = `Application Loader: ${ appleId } ` ;
17
+
18
+ console . log ( `Notarizing with Apple ID "${ appleId } " and keychain item "${ appleIdKeychainItem } "` ) ;
19
+
20
+ const { appOutDir} = context ;
21
+ const productFilename = context . packager . appInfo . productFilename ;
22
+ await notarize ( {
23
+ appBundleId : appId ,
24
+ appPath : `${ appOutDir } /${ productFilename } .app` ,
25
+ appleId,
26
+ appleIdPassword : `@keychain:${ appleIdKeychainItem } `
27
+ } ) ;
28
+ } ;
29
+
30
+ const afterSign = async function ( context ) {
31
+ const { electronPlatformName} = context ;
32
+
33
+ switch ( electronPlatformName ) {
34
+ case 'mas' : // macOS build for Mac App Store
35
+ break ;
36
+ case 'darwin' : // macOS build NOT for Mac App Store
37
+ await notarizeMacBuild ( context ) ;
38
+ break ;
39
+ }
40
+ } ;
41
+
42
+ module . exports = afterSign ;
Original file line number Diff line number Diff line change @@ -52,11 +52,20 @@ const runBuilder = function (targetGroup) {
52
52
const platformFlag = getPlatformFlag ( ) ;
53
53
const command = `electron-builder ${ platformFlag } ${ targetGroup } ` ;
54
54
console . log ( `running: ${ command } ` ) ;
55
- spawnSync ( command , {
55
+ const result = spawnSync ( command , {
56
56
env : childEnvironment ,
57
57
shell : true ,
58
58
stdio : 'inherit'
59
59
} ) ;
60
+ if ( result . error ) {
61
+ throw result . error ;
62
+ }
63
+ if ( result . signal ) {
64
+ throw new Error ( `Child process terminated due to signal ${ result . signal } ` ) ;
65
+ }
66
+ if ( result . status ) {
67
+ throw new Error ( `Child process returned status code ${ result . status } ` ) ;
68
+ }
60
69
} ;
61
70
62
71
/**
@@ -69,8 +78,10 @@ const calculateTargets = function () {
69
78
// run in two passes so we can skip signing the appx
70
79
return [ 'nsis' , 'appx' ] ;
71
80
case 'darwin' :
72
- // run in one pass for slightly better speed
73
- return [ 'dmg mas' ] ;
81
+ // Running 'dmg' and 'mas' in the same pass causes electron-builder to skip signing the non-MAS app copy.
82
+ // Running them as separate passes means they both get signed.
83
+ // Seems like a bug in electron-builder...
84
+ return [ 'dmg' , 'mas' ] ;
74
85
}
75
86
throw new Error ( `Could not determine targets for platform: ${ process . platform } ` ) ;
76
87
} ;
You can’t perform that action at this time.
0 commit comments