Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notarise the macOS app #11119

Merged
merged 8 commits into from Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -111,6 +111,7 @@
"electron-builder": "^21.2.0",
"electron-builder-squirrel-windows": "^21.2.0",
"electron-devtools-installer": "^2.2.4",
"electron-notarize": "^0.1.1",
"eslint": "^5.8.0",
"eslint-config-google": "^0.7.1",
"eslint-plugin-babel": "^4.1.2",
Expand Down Expand Up @@ -188,6 +189,7 @@
"buildResources": "electron_app/build",
"output": "electron_app/dist",
"app": "electron_app"
}
},
"afterSign": "scripts/electron_afterSign.js"
}
}
8 changes: 8 additions & 0 deletions scripts/electron-package.sh
Expand Up @@ -67,6 +67,14 @@ if [ ! -f package.json ]; then
exit
fi

if [ -z "$NOTARIZE_APPLE_ID" ]; then
echo "NOTARIZE_APPLE_ID is not set"
exit
fi

# Test that altool can get its credentials for notarising the mac app
xcrun altool -u "$NOTARIZE_APPLE_ID" -p '@keychain:NOTARIZE_CREDS' --list-apps || exit

echo "Building $version using Update base URL $update_base_url"

projdir=`pwd`
Expand Down
26 changes: 26 additions & 0 deletions scripts/electron_afterSign.js
@@ -0,0 +1,26 @@
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who will set this env var? Can we manually extract it from keychain with keychain find-generic-password ... or similar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just going to put it in the ~/.profile on the build machine. I'd hoped we'd be be able to just get it out of the keychain but I can't work out how to get the entry in a place in the keychain where both altool and security can find it...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I see... Well, probably it's fine. 😄

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the current method for getting this set up? I've tried NOTARIZE_CREDS=foo yarn build:electron:macos to no avail...

Copy link
Collaborator

@jryans jryans Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this in #riot-dev.

if (userId === undefined) {
throw new Exception("User ID not found. Set NOTARIZE_APPLE_ID.");
}

const appName = context.packager.appInfo.productFilename;

console.log("Notarising macOS app. This may be some time.");
return await notarize({
appBundleId: 'im.riot.app',
appPath: `${appOutDir}/${appName}.app`,
appleId: userId,
appleIdPassword: '@keychain:NOTARIZE_CREDS',
});
};
10 changes: 9 additions & 1 deletion yarn.lock
Expand Up @@ -3134,6 +3134,14 @@ electron-devtools-installer@^2.2.4:
rimraf "^2.5.2"
semver "^5.3.0"

electron-notarize@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-0.1.1.tgz#c3563d70c5e7b3315f44e8495b30050a8c408b91"
integrity sha512-TpKfJcz4LXl5jiGvZTs5fbEx+wUFXV5u8voeG5WCHWfY/cdgdD8lDZIZRqLVOtR3VO+drgJ9aiSHIO9TYn/fKg==
dependencies:
debug "^4.1.1"
fs-extra "^8.0.1"

electron-publish@21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d"
Expand Down Expand Up @@ -4083,7 +4091,7 @@ fs-extra@^0.30.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"

fs-extra@^8.1.0:
fs-extra@^8.0.1, fs-extra@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
Expand Down