|
1 |
| -const { notarize } = require('@electron/notarize') |
2 |
| - |
3 |
| -module.exports = async (context) => { |
4 |
| - if (process.platform !== 'darwin') return |
| 1 | +console.log('afterSign hook triggered') |
5 | 2 |
|
6 |
| - console.log('aftersign hook triggered, start to notarize app.') |
| 3 | +require('dotenv').config() |
7 | 4 |
|
8 |
| - if (!process.env.CI) { |
9 |
| - console.log(`skipping notarizing, not in CI.`) |
10 |
| - return |
11 |
| - } |
| 5 | +const { notarize } = require('@electron/notarize') |
12 | 6 |
|
13 |
| - if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) { |
14 |
| - console.warn('skipping notarizing, APPLE_ID and APPLE_ID_PASS env variables must be set.') |
| 7 | +exports.default = async function notarizing(context) { |
| 8 | + const { electronPlatformName, appOutDir } = context |
| 9 | + if (electronPlatformName !== 'darwin') { |
15 | 10 | return
|
16 | 11 | }
|
17 | 12 |
|
18 |
| - const appId = 'net.sltt-bible.app' |
19 |
| - |
20 |
| - const { appOutDir } = context |
| 13 | + console.log('notarizing...') |
21 | 14 |
|
22 | 15 | const appName = context.packager.appInfo.productFilename
|
23 | 16 |
|
24 |
| - try { |
25 |
| - await notarize({ |
26 |
| - appBundleId: appId, |
27 |
| - appPath: `${appOutDir}/${appName}.app`, |
28 |
| - appleId: process.env.APPLE_ID, |
29 |
| - appleIdPassword: process.env.APPLEIDPASS |
30 |
| - }) |
31 |
| - } catch (error) { |
32 |
| - console.error(error) |
| 17 | + // Get appleId and appleIdPassword from environment variables. |
| 18 | + // These values are in the .env file. |
| 19 | + // appleId: email address you use to login to App Store Connect |
| 20 | + // appleIdPassword: app-specific password generated by appleid.apple.com |
| 21 | + const { appleId, appleIdPassword, teamId } = process.env |
| 22 | + |
| 23 | + if (!appleId || !appleIdPassword || !teamId) { |
| 24 | + console.error('Missing Apple ID or Apple ID password or Team ID') |
| 25 | + return |
33 | 26 | }
|
34 | 27 |
|
35 |
| - console.log(`done notarizing ${appId}.`) |
| 28 | + return await notarize({ |
| 29 | + appBundleId: 'net.sltt-bible.app', |
| 30 | + appPath: `${appOutDir}/${appName}.app`, |
| 31 | + appleId, |
| 32 | + appleIdPassword, |
| 33 | + tool: 'notarytool', |
| 34 | + teamId, |
| 35 | + }) |
36 | 36 | }
|
0 commit comments