forked from oldj/SwitchHosts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotarize.js
43 lines (37 loc) · 1.11 KB
/
notarize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* notarize.js
*
* @see https://oldj.net/blog/2019/12/29/electron-builder-sign-and-notarize-for-macos
*/
require('dotenv').config()
const { notarize } = require('electron-notarize')
exports.default = async function notarizing(context) {
const appName = context.packager.appInfo.productFilename
const { electronPlatformName, appOutDir } = context
console.log(`in notarize, ${electronPlatformName}...`)
if (electronPlatformName !== 'darwin') {
return
}
if (process.env.MAKE_FOR === 'dev' || process.env.SKIP_NOTARIZATION) {
console.log('skip notarization.')
return // for dev, skip notarization
}
let appPath = `${appOutDir}/${appName}.app`
let { appleId, appBundleId, ascProvider, appleIdPassword } = process.env
if (!appleIdPassword) {
appleIdPassword = `@keychain:Apple Notarize: ${appleId}`
}
if (!appleId || !appBundleId || !ascProvider || !appleIdPassword) {
console.log('Not notarized.')
return
}
console.log('Start notarizing...')
await notarize({
appBundleId,
appPath,
ascProvider,
appleId,
appleIdPassword,
})
console.log('Notarize done.')
}