-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
notarize.ts
68 lines (56 loc) · 1.57 KB
/
notarize.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2019 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import path from 'path';
import type { AfterPackContext } from 'electron-builder';
import { notarize } from '@electron/notarize';
import * as packageJson from '../../package.json';
export async function afterSign({
appOutDir,
packager,
electronPlatformName,
}: AfterPackContext): Promise<void> {
if (electronPlatformName !== 'darwin') {
console.log('notarize: Skipping, not on macOS');
return;
}
const { productFilename } = packager.appInfo;
const appPath = path.join(appOutDir, `${productFilename}.app`);
const appBundleId = packageJson.build.appId;
if (!appBundleId) {
throw new Error(
'appBundleId must be provided in package.json: build.appId'
);
}
const appleId = process.env.APPLE_USERNAME;
if (!appleId) {
console.warn(
'appleId must be provided in environment variable APPLE_USERNAME'
);
return;
}
const appleIdPassword = process.env.APPLE_PASSWORD;
if (!appleIdPassword) {
console.warn(
'appleIdPassword must be provided in environment variable APPLE_PASSWORD'
);
return;
}
const teamId = process.env.APPLE_TEAM_ID;
if (!teamId) {
console.warn(
'teamId must be provided in environment variable APPLE_TEAM_ID'
);
return;
}
console.log('Notarizing with...');
console.log(` primaryBundleId: ${appBundleId}`);
console.log(` username: ${appleId}`);
console.log(` file: ${appPath}`);
await notarize({
appBundleId,
appPath,
appleId,
appleIdPassword,
teamId,
});
}