Skip to content

Commit

Permalink
Run notarization in afterPack script
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Feb 24, 2022
1 parent eebd252 commit 5e113f8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 91 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"generate": "npm-run-all build-protobuf transpile sass get-expire-time copy-and-concat",
"build-release": "yarn run build",
"sign-release": "node ts/updater/generateSignature.js",
"notarize": "node ts/build/notarize.js",
"notarize": "echo 'No longer necessary'",
"get-strings": "node ts/scripts/get-strings.js",
"get-expire-time": "node ts/scripts/get-expire-time.js",
"copy-and-concat": "node ts/scripts/copy-and-concat.js",
Expand Down
90 changes: 0 additions & 90 deletions ts/build/notarize.ts

This file was deleted.

4 changes: 4 additions & 0 deletions ts/scripts/after-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import { afterPack as fuseElectron } from './fuse-electron';
import { afterPack as mergeASARs } from './merge-macos-asars';
import { afterPack as copyPacks } from './copy-language-packs';
import { afterPack as pruneMacOSRelease } from './prune-macos-release';
import { afterPack as notarize } from './notarize';

export async function afterPack(context: AfterPackContext): Promise<void> {
await pruneMacOSRelease(context);
await mergeASARs(context);
await fuseElectron(context);
await copyPacks(context);

// This must be the last step
await notarize(context);
}
62 changes: 62 additions & 0 deletions ts/scripts/notarize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2019-2020 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';

/* eslint-disable no-console */

export async function afterPack({
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;
}

console.log('Notarizing with...');
console.log(` primaryBundleId: ${appBundleId}`);
console.log(` username: ${appleId}`);
console.log(` file: ${appPath}`);

// eslint-disable-next-line no-await-in-loop
await notarize({
appBundleId,
appPath,
appleId,
appleIdPassword,
});
}

0 comments on commit 5e113f8

Please sign in to comment.