Skip to content

Commit 9c9d7c6

Browse files
author
Christopher Willis-Ford
committed
notarize non-MAS macOS build (required for 10.15)
1 parent 6a33d41 commit 9c9d7c6

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

electron-builder.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ directories:
33
output: dist
44
appId: edu.mit.scratch.scratch-desktop
55
productName: "Scratch Desktop"
6+
afterSign: "scripts/afterSign.js"
67
mac:
78
category: public.app-category.education
89
hardenedRuntime: true

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"electron": "^6.1.7",
3939
"electron-builder": "^22.2.0",
4040
"electron-devtools-installer": "^2.2.4",
41+
"electron-notarize": "^0.2.1",
4142
"electron-store": "^3.3.0",
4243
"electron-webpack": "^2.7.4",
4344
"eslint": "^5.16.0",

scripts/afterSign.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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;

0 commit comments

Comments
 (0)