Skip to content

Commit

Permalink
chore: macOS notarizing
Browse files Browse the repository at this point in the history
This adds scripts that run electron-notarize
as additional manual or build steps on darvin runtime, loosly following
https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/

Context:
#1211

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Mar 9, 2020
1 parent b04f9dd commit 1e055e5
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
out
dist
.cache
.env
config.gypi
assets/webui
*.nupkg
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ Other languages are periodically pulled from [Transifex](https://www.transifex.c
- Publish local changes and the tag to GitHub repo: `git push && git push origin vA.B.C`
- Wait for the CI to upload the binaries to the draft release (a new one will be created if you haven't drafted one).
- The `latest.yml, latest-mac.yml, latest-linux.yml` files on the release are used by the app to determine when an app update is available. Once a release is published, users should recieve the app update. See: https://www.electron.build/auto-update.
- Notarize `.dmg` at Apple (context: [#1365](https://github.com/ipfs-shipyard/ipfs-desktop/issues/1211))
1. Download `.dmg` from `https://github.com/ipfs-shipyard/ipfs-desktop/releases/vA.B.C`
2. Run `node pkgs/macos/notarize-cli.js ./IPFS-Desktop-A.B.C.dmg`
- Update [Homebrew Cask](https://github.com/Homebrew/homebrew-cask/blob/master/CONTRIBUTING.md#updating-a-cask).
- Update Chocolatey package:
1. Update the version number on [ipfs-desktop.nuspec](./pkgs/chocolatey/ipfs-desktop.nuspec#L5)
Expand Down
6 changes: 6 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ directories:

asarUnpack: 'out/**/scripts/**/*'

afterSign: './pkgs/macos/notarize-build.js'

mac:
category: public.app-category.utilities
darkModeSupport: true
hardenedRuntime: true
gatekeeperAssess: false
entitlements: './pkgs/macos/entitlements.mac.plist'
entitlementsInherit: './pkgs/macos/entitlements.mac.plist'

dmg:
iconSize: 160
Expand Down
12 changes: 11 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
"cross-env": "^6.0.3",
"delay": "^4.3.0",
"dirty-chai": "^2.0.1",
"dotenv": "^8.2.0",
"electron": "^7.1.11",
"electron-builder": "^22.3.2",
"electron-notarize": "^0.2.1",
"mocha": "^6.2.2",
"npm-run-all": "^4.1.5",
"pre-commit": "^1.2.2",
Expand Down
10 changes: 10 additions & 0 deletions pkgs/macos/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
</dict>
</plist>
22 changes: 22 additions & 0 deletions pkgs/macos/notarize-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require('dotenv').config()
const { notarize } = require('electron-notarize')

// electron-build hook to be used in electron-build pipeline in the future
// ===========================================================================
// Note: for now we don't use this at the moment.
// Run ./notarize-cli.js instead
exports.default = async function notarizing (context) {
const { electronPlatformName, appOutDir } = context
if (electronPlatformName !== 'darwin') return
// skip notarization if secrets are not present in env
if (!process.env.APPLEID || !process.env.APPLEIDPASS) return

const appName = context.packager.appInfo.productFilename

return notarize({
appBundleId: 'io.ipfs.desktop',
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEIDPASS
})
}