From ff70339aadaac760281c85ea53be8b86420847a9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 9 Oct 2019 16:29:24 +0100 Subject: [PATCH] Working branch for notarisation --- package.json | 3 ++- scripts/electron_afterSign.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/electron_afterSign.js diff --git a/package.json b/package.json index bd05b090..cd4f4cd2 100644 --- a/package.json +++ b/package.json @@ -188,6 +188,7 @@ "buildResources": "electron_app/build", "output": "electron_app/dist", "app": "electron_app" - } + }, + "afterSign": "scripts/electron_afterSign.js" } } diff --git a/scripts/electron_afterSign.js b/scripts/electron_afterSign.js new file mode 100644 index 00000000..bb554219 --- /dev/null +++ b/scripts/electron_afterSign.js @@ -0,0 +1,25 @@ +const { notarize } = require('electron-notarize'); + +exports.default = async function(context) { + const { electronPlatformName, appOutDir } = context; + if (electronPlatformName !== 'darwin') { + return; + } + + // We get the password from keychain. The keychain stores + // user IDs too, but apparently altool can't get the user ID + // from the keychain, so we need to get it from the environment. + const userId = process.env.NOTARIZE_APPLE_ID; + if (userId === undefined) { + throw new Exception("User ID not found. Set NOTARIZE_APPLE_ID."); + } + + const appName = context.packager.appInfo.productFilename; + + return await notarize({ + appBundleId: 'im.riot.app', + appPath: `${appOutDir}/${appName}.app`, + appleId: userId, + appleIdPassword: '@keychain:NOTARIZE_CREDS, + }); +};