Skip to content

Commit 8d4442f

Browse files
authored
Notarize app with Apple (#390)
* Notarize app on the release workflow * Remove pack step
1 parent b78d3ce commit 8d4442f

File tree

6 files changed

+53
-9
lines changed

6 files changed

+53
-9
lines changed

.github/workflows/build-app.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
- name: Build
2727
run: yarn build
2828

29-
- name: Pack (electron-builder)
30-
run: yarn pack
31-
3229
- name: Make macOS (electron-builder)
3330
env:
3431
CSC_LINK: ${{ secrets.mac_certs }}

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ jobs:
3232
OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }}
3333
run: yarn build
3434

35-
- name: Pack (electron-builder)
36-
run: yarn pack
37-
3835
- name: Publish macOS (electron-builder)
3936
env:
37+
APPLEID_USERNAME: ${{ secrets.appleid_username }}
38+
APPLEID_PASSWORD: ${{ secrets.appleid_password }}
4039
CSC_LINK: ${{ secrets.mac_certs }}
4140
CSC_KEY_PASSWORD: ${{ secrets.mac_certs_password }}
4241
GH_TOKEN: ${{ secrets.gh_token }}
42+
NOTARIZE: true
4343
run: yarn electron-builder --publish onTagOrDraft

entitlements/entitlements.mac.plist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
6+
<true/>
7+
</dict>
8+
</plist>

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"scripts": {
77
"build": "webpack --config webpack.prod.js",
88
"watch": "webpack --config webpack.common.js --watch",
9-
"pack": "electron-builder --dir",
109
"make:macos": "electron-builder --mac",
1110
"prettier-check": "prettier --check 'src/**/*.{js,ts,tsx}'",
1211
"prettier": "prettier --single-quote --trailing-comma es5 --write 'src/**/*.{js,ts,tsx}'",
@@ -74,13 +73,19 @@
7473
"category": "public.app-category.developer-tools",
7574
"icon": "assets/images/app-icon.icns",
7675
"identity": "Emmanouil Konstantinidis (3YP8SXP3BF)",
76+
"hardenedRuntime": true,
77+
"gatekeeperAssess": false,
78+
"entitlements": "./entitlements/entitlements.mac.plist",
79+
"entitlementsInherit": "./entitlements/entitlements.mac.plist",
7780
"publish": [
7881
"github"
7982
]
8083
},
8184
"dmg": {
82-
"icon": "assets/images/app-icon.icns"
83-
}
85+
"icon": "assets/images/app-icon.icns",
86+
"sign": false
87+
},
88+
"afterSign": "scripts/notarize.js"
8489
},
8590
"dependencies": {
8691
"@primer/octicons-react": "^9.6.0",
@@ -121,6 +126,7 @@
121126
"@types/styled-components": "^5.0.1",
122127
"electron": "^8.2.0",
123128
"electron-builder": "^22.4.1",
129+
"electron-notarize": "^0.2.1",
124130
"jest": "^25.2.3",
125131
"nock": "^12.0.3",
126132
"prettier": "=2.0.2",

scripts/notarize.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { notarize } = require('electron-notarize');
2+
3+
const packageJson = require('../package.json');
4+
const appBundleId = packageJson.build.appId;
5+
6+
const notarizeApp = async (context) => {
7+
const { electronPlatformName, appOutDir } = context;
8+
const appName = context.packager.appInfo.productFilename;
9+
const isMacOS = electronPlatformName === 'darwin';
10+
const shouldNotarize = process.env.NOTARIZE === 'true';
11+
12+
if (!shouldNotarize || !isMacOS) {
13+
console.log('Either should not notarize or not building for macOS.');
14+
return;
15+
}
16+
17+
return await notarize({
18+
appBundleId,
19+
appPath: `${appOutDir}/${appName}.app`,
20+
appleId: process.env.APPLEID_USERNAME,
21+
appleIdPassword: process.env.APPLEID_PASSWORD,
22+
});
23+
};
24+
25+
exports.default = notarizeApp;

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,14 @@ electron-builder@^22.4.1:
23662366
update-notifier "^4.1.0"
23672367
yargs "^15.1.0"
23682368

2369+
electron-notarize@^0.2.1:
2370+
version "0.2.1"
2371+
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-0.2.1.tgz#759e8006decae19134f82996ed910db26d9192cc"
2372+
integrity sha512-oZ6/NhKeXmEKNROiFmRNfytqu3cxqC95sjooG7kBXQVEUSQkZnbiAhxVh5jXngL881G197pbwpeVPJyM7Ikmxw==
2373+
dependencies:
2374+
debug "^4.1.1"
2375+
fs-extra "^8.1.0"
2376+
23692377
electron-positioner@^4.1.0:
23702378
version "4.1.0"
23712379
resolved "https://registry.yarnpkg.com/electron-positioner/-/electron-positioner-4.1.0.tgz#e158f8f6aabd6725a8a9b4f2279b9504bcbea1b0"

0 commit comments

Comments
 (0)