Skip to content

Commit 21ea6c6

Browse files
authored
Merge pull request element-hq#11119 from vector-im/dbkr/notarise
Notarise the macOS app
2 parents 38fe2c2 + 0712231 commit 21ea6c6

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"electron-builder": "^21.2.0",
112112
"electron-builder-squirrel-windows": "^21.2.0",
113113
"electron-devtools-installer": "^2.2.4",
114+
"electron-notarize": "^0.1.1",
114115
"eslint": "^5.8.0",
115116
"eslint-config-google": "^0.7.1",
116117
"eslint-plugin-babel": "^4.1.2",
@@ -188,6 +189,7 @@
188189
"buildResources": "electron_app/build",
189190
"output": "electron_app/dist",
190191
"app": "electron_app"
191-
}
192+
},
193+
"afterSign": "scripts/electron_afterSign.js"
192194
}
193195
}

‎scripts/electron-package.sh‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ if [ ! -f package.json ]; then
6767
exit
6868
fi
6969

70+
if [ -z "$NOTARIZE_APPLE_ID" ]; then
71+
echo "NOTARIZE_APPLE_ID is not set"
72+
exit
73+
fi
74+
75+
# Test that altool can get its credentials for notarising the mac app
76+
xcrun altool -u "$NOTARIZE_APPLE_ID" -p '@keychain:NOTARIZE_CREDS' --list-apps || exit
77+
7078
echo "Building $version using Update base URL $update_base_url"
7179

7280
projdir=`pwd`

‎scripts/electron_afterSign.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { notarize } = require('electron-notarize');
2+
3+
exports.default = async function(context) {
4+
const { electronPlatformName, appOutDir } = context;
5+
if (electronPlatformName !== 'darwin') {
6+
return;
7+
}
8+
9+
// We get the password from keychain. The keychain stores
10+
// user IDs too, but apparently altool can't get the user ID
11+
// from the keychain, so we need to get it from the environment.
12+
const userId = process.env.NOTARIZE_APPLE_ID;
13+
if (userId === undefined) {
14+
throw new Exception("User ID not found. Set NOTARIZE_APPLE_ID.");
15+
}
16+
17+
const appName = context.packager.appInfo.productFilename;
18+
19+
console.log("Notarising macOS app. This may be some time.");
20+
return await notarize({
21+
appBundleId: 'im.riot.app',
22+
appPath: `${appOutDir}/${appName}.app`,
23+
appleId: userId,
24+
appleIdPassword: '@keychain:NOTARIZE_CREDS',
25+
});
26+
};

‎yarn.lock‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,14 @@ electron-devtools-installer@^2.2.4:
31343134
rimraf "^2.5.2"
31353135
semver "^5.3.0"
31363136

3137+
electron-notarize@^0.1.1:
3138+
version "0.1.1"
3139+
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-0.1.1.tgz#c3563d70c5e7b3315f44e8495b30050a8c408b91"
3140+
integrity sha512-TpKfJcz4LXl5jiGvZTs5fbEx+wUFXV5u8voeG5WCHWfY/cdgdD8lDZIZRqLVOtR3VO+drgJ9aiSHIO9TYn/fKg==
3141+
dependencies:
3142+
debug "^4.1.1"
3143+
fs-extra "^8.0.1"
3144+
31373145
electron-publish@21.2.0:
31383146
version "21.2.0"
31393147
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d"
@@ -4083,7 +4091,7 @@ fs-extra@^0.30.0:
40834091
path-is-absolute "^1.0.0"
40844092
rimraf "^2.2.8"
40854093

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

0 commit comments

Comments
 (0)