-
Notifications
You must be signed in to change notification settings - Fork 1
/
after-sign-hook.js
56 lines (45 loc) · 1.58 KB
/
after-sign-hook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db
const fs = require('fs');
const path = require('path');
const electronConfig = JSON.parse(process.env.electronConfig);
const electronNotarize = require('electron-notarize');
module.exports = async function (params) {
// notarize app on Mac OS only.
if (process.platform !== 'darwin' ||
!process.env.appleId ||
!process.env.appleIdPassword ||
!process.env.teamId
) {
if (process.platform === 'darwin') {
console.log('[Error] Abort application notarization');
console.log('appleId:', process.env.appleId);
console.log('appleIdPassword:', process.env.appleIdPassword);
console.log('teamId:', process.env.teamId);
}
return;
}
// console.log('afterSign hook triggered', params);
console.log('> afterSign hook triggered');
// Same appId in electron-builder.
let appId = electronConfig.appId;
let appPath = path.join(params.appOutDir, `${params.packager.appInfo.productFilename}.app`);
if (!fs.existsSync(appPath)) {
throw new Error(`Cannot find application at: ${appPath}`);
}
console.log(`> Notarizing ${appId} in ${appPath}`);
try {
const config = {
tool: 'notarytool',
appBundleId: appId,
appPath: appPath,
appleId: process.env.appleId,
appleIdPassword: process.env.appleIdPassword,
teamId: process.env.teamId,
};
console.log('notarization config:', config);
await electronNotarize.notarize(config);
} catch (error) {
console.error(error);
}
console.log(`Done notarizing ${appId}`);
};