-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run notarization in afterPack script
- Loading branch information
1 parent
eebd252
commit 5e113f8
Showing
4 changed files
with
67 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
} |