-
Notifications
You must be signed in to change notification settings - Fork 4
/
electron-builder.cjs
138 lines (130 loc) · 3.68 KB
/
electron-builder.cjs
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
const { execSync } = require('child_process');
const config = {
appId: 'com.decentraland.creatorshub',
directories: {
output: 'dist',
buildResources: 'buildResources',
},
files: ['packages/**/dist/**'],
linux: {
target: 'deb',
},
productName: 'Decentraland Creator Hub',
artifactName: '${productName}-${os}-${arch}.${ext}',
win: {
publisherName: 'Decentraland Foundation',
appId: 'Decentraland.CreatorsHub',
icon: 'buildResources/icon.ico',
target: [
{
target: 'nsis',
arch: ['x64'],
},
],
extraResources: ['buildResources/icon.ico'],
verifyUpdateCodeSignature: false,
},
nsis: {
createDesktopShortcut: true,
installerSidebar: 'buildResources/background.bmp',
installerIcon: 'buildResources/icon.ico',
},
dmg: {
title: 'Decentraland Creator Hub Installer',
background: 'buildResources/background.png',
window: {
width: 714,
height: 472,
},
contents: [
{
x: 230,
y: 215,
type: 'file',
},
{
x: 460,
y: 215,
type: 'link',
path: '/Applications',
},
],
writeUpdateInfo: false,
},
mac: {
target: [
{
target: 'dmg',
arch: 'arm64',
},
{
target: 'dmg',
arch: 'x64',
},
{
target: 'zip',
arch: 'arm64',
},
{
target: 'zip',
arch: 'x64',
},
],
},
asarUnpack: ['./node_modules/npm/**/*', './package.json'],
publish: [
{
provider: 'github',
vPrefixedTagName: false,
},
],
};
if (process.env.CODE_SIGN_SCRIPT_PATH) {
console.log('CODE_SIGN_SCRIPT_PATH found in env vars:', process.env.CODE_SIGN_SCRIPT_PATH);
config.win.sign = configuration => {
console.log('Requested signing for ', configuration.path);
// Only proceed if the installer .exe file is in the configuration path - skip signing everything else
if (!/Decentraland Creator Hub-win-x64.exe$/.test(configuration.path)) {
console.log('This is not the installer .exe, skip signing');
return true;
}
const scriptPath = process.env.CODE_SIGN_SCRIPT_PATH;
try {
// Execute the sign script synchronously
process.env.INPUT_COMMAND = 'sign';
process.env.INPUT_FILE_PATH = configuration.path;
const env = {
command: process.env.INPUT_COMMAND,
username: process.env.INPUT_USERNAME,
password: process.env.INPUT_PASSWORD,
credential_id: process.env.INPUT_CREDENTIAL_ID,
totp_secret: process.env.INPUT_TOTP_SECRET,
file_path: process.env.INPUT_FILE_PATH,
output_path: process.env.INPUT_OUTPUT_PATH,
malware_block: process.env.INPUT_MALWARE_BLOCK,
override: process.env.INPUT_OVERRIDE,
clean_logs: process.env.INPUT_CLEAN_LOGS,
environment_name: process.env.INPUT_ENVIRONMENT_NAME,
jvm_max_memory: process.env.INPUT_JVM_MAX_MEMORY,
};
console.log('env:', JSON.stringify(env, null, 2));
const output = execSync(`node "${scriptPath}"`, {
env: { ...process.env, ...env },
}).toString();
console.log(`Script output: ${output}`);
} catch (error) {
console.error(`Error executing script: ${error.message}`);
if (error.stdout) {
console.log(`Script stdout: ${error.stdout.toString()}`);
}
if (error.stderr) {
console.error(`Script stderr: ${error.stderr.toString()}`);
}
return false;
}
return true; // Return true at the end of successful signing
};
// sign only for Windows 10 and above - adjust for your code as needed
config.win.signingHashAlgorithms = ['sha256'];
}
module.exports = config;