Repository navigation
Expand file tree
/
Copy pathnotarize.js
More file actions
75 lines (63 loc) · 2.19 KB
/
Copy pathnotarize.js
File metadata and controls
75 lines (63 loc) · 2.19 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const { notarize } = require('@electron/notarize');
const { execFileSync } = require('child_process');
const path = require('path');
const fs = require('fs');
function isAppSigned(appPath) {
try {
execFileSync('codesign', ['--verify', appPath], { stdio: 'pipe' });
return true;
} catch {
return false;
}
}
exports.default = async function notarizing(context) {
const {
electronPlatformName,
appOutDir,
arch
} = context;
if (electronPlatformName !== 'darwin') {
return;
}
const appName = context.packager.appInfo.productFilename;
const appPath = path.join(appOutDir, `${appName}.app`);
console.log('============ Notarization Info ============');
console.log('App Out Dir:', appOutDir);
console.log('App Name:', appName);
console.log('App Path:', appPath);
console.log('Architecture:', arch);
console.log('==========================================');
if (!fs.existsSync(appPath)) {
console.error(`App bundle not found at: ${appPath}`);
console.error('Skipping notarization');
return;
}
// electron-builder skips signing on pull requests unless CSC_FOR_PULL_REQUEST=true
if (process.env.GITHUB_EVENT_NAME === 'pull_request') {
console.log('Skipping notarization: pull request builds are unsigned');
return;
}
if (!isAppSigned(appPath)) {
console.log('Skipping notarization: app is not signed');
return;
}
if (!process.env.APPLE_ID || !process.env.APPLE_APP_SPECIFIC_PASSWORD || !process.env.APPLE_TEAM_ID) {
console.log('Skipping notarization: Apple credentials not provided');
return;
}
console.log('Starting notarization...');
try {
await notarize({
tool: 'notarytool',
appBundleId: 'org.sienci.gsender',
appPath: appPath,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
});
console.log('✓ Notarization successful');
} catch (error) {
console.error('✗ Notarization failed:', error);
throw error;
}
};