2022-06-03 21:07:51 +00:00
|
|
|
// Copyright 2019-2022 Signal Messenger, LLC
|
2022-02-24 19:39:26 +00:00
|
|
|
// 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';
|
|
|
|
|
2022-02-24 20:24:48 +00:00
|
|
|
export async function afterSign({
|
2022-02-24 19:39:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-05-03 17:07:16 +00:00
|
|
|
const teamId = process.env.APPLE_TEAM_ID;
|
|
|
|
if (!teamId) {
|
|
|
|
console.warn(
|
|
|
|
'teamId must be provided in environment variable APPLE_TEAM_ID'
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-24 19:39:26 +00:00
|
|
|
console.log('Notarizing with...');
|
|
|
|
console.log(` primaryBundleId: ${appBundleId}`);
|
|
|
|
console.log(` username: ${appleId}`);
|
|
|
|
console.log(` file: ${appPath}`);
|
|
|
|
|
|
|
|
await notarize({
|
2022-05-03 17:07:16 +00:00
|
|
|
tool: 'notarytool',
|
2022-02-24 19:39:26 +00:00
|
|
|
appBundleId,
|
|
|
|
appPath,
|
|
|
|
appleId,
|
|
|
|
appleIdPassword,
|
2022-05-03 17:07:16 +00:00
|
|
|
teamId,
|
2022-02-24 19:39:26 +00:00
|
|
|
});
|
|
|
|
}
|