Skip to content

Commit 956327c

Browse files
committed
Notarize Mac builds in CI
This will be required for Mac after 10.15 is released. It's fairly easy to do, but needs a few new variables set in Travis, and an extra post-package build step.
1 parent c678968 commit 956327c

File tree

6 files changed

+88
-1
lines changed

6 files changed

+88
-1
lines changed

electron-forge.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,7 @@ module.exports = {
7676
"owner": "httptoolkit",
7777
"name": "httptoolkit-desktop"
7878
},
79+
"hooks": {
80+
"postPackage": require("./src/hooks/post-package.js")
81+
}
7982
}

package-lock.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"babel-preset-env": "^1.7.0",
4141
"electron": "^4.1.4",
4242
"electron-forge": "^5.2.3",
43+
"electron-notarize": "^0.1.1",
4344
"electron-prebuilt-compile": "4.0.0",
4445
"httptoolkit-server": "^0.1.17",
4546
"lodash": "^4.17.13",

src/after-copy-insert-server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ const serverVersion: string = 'v' + packageJsonLock.dependencies['httptoolkit-se
1919
* and because it makes it possible for users to run the server directly
2020
* with minimal effort, if they so choose.
2121
*/
22-
export = async function (buildPath: string, _electronVersion: string, platform: string, arch: string, callback: Function) {
22+
export = async function (
23+
buildPath: string,
24+
_electronVersion: string,
25+
platform: string,
26+
arch: string,
27+
callback: Function
28+
) {
2329
try {
2430
console.log(`Downloading httptoolkit-server ${serverVersion} for ${platform}-${arch}`);
2531

src/hooks/post-package.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('ts-node/register');
2+
module.exports = require('../notarize');

src/notarize.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { notarize } from 'electron-notarize'
2+
3+
const projectRoot = require('path').resolve(__dirname, '..');
4+
5+
export = async function () {
6+
if (process.platform !== 'darwin') {
7+
console.log('Skipping notarization - not building for Mac');
8+
return;
9+
}
10+
11+
console.log('Notarizing...');
12+
13+
return notarize({
14+
appBundleId: 'tech.httptoolkit.desktop',
15+
appPath: projectRoot + '/out/HTTP Toolkit-darwin-x64/HTTP Toolkit.app',
16+
appleId: process.env.APPLE_ID!,
17+
appleIdPassword: process.env.APPLE_ID_PASSWORD!
18+
}).catch((e) => {
19+
console.error(e);
20+
throw e;
21+
});
22+
}

0 commit comments

Comments
 (0)