Skip to content

Commit d077e79

Browse files
author
Christopher Willis-Ford
committed
skip code signing for AppX builds
1 parent 9ec118e commit d077e79

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rimraf ./dist/ ./static/assets/",
1313
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
1414
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",
15-
"dist": "npm run build-gui && npm run fetch && npm run compile -p && electron-builder",
15+
"dist": "npm run build-gui && npm run fetch && npm run compile -p && node ./scripts/electron-builder-wrapper.js",
1616
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null",
1717
"lint": "eslint --cache --color --ext .jsx,.js ."
1818
},

scripts/electron-builder-wrapper.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const {spawnSync} = require('child_process');
2+
3+
const stripCSC = function (environment) {
4+
const {
5+
CSC_LINK: _CSC_LINK,
6+
CSC_KEY_PASSWORD: _CSC_KEY_PASSWORD,
7+
WIN_CSC_LINK: _WIN_CSC_LINK,
8+
WIN_CSC_KEY_PASSWORD: _WIN_CSC_KEY_PASSWORD,
9+
...strippedEnvironment
10+
} = environment;
11+
return strippedEnvironment;
12+
};
13+
14+
const getPlatformFlag = function () {
15+
switch (process.platform) {
16+
case 'win32': return '--windows';
17+
case 'darwin': return '--macos';
18+
case 'linux': return '--linux';
19+
}
20+
throw new Error(`Could not determine platform flag for platform: ${process.platform}`);
21+
}
22+
23+
const runBuilder = function (targetGroup) {
24+
// the appx build fails if CSC_* or WIN_CSC_* variables are set
25+
const shouldStripCSC = (targetGroup === 'appx');
26+
const childEnvironment = shouldStripCSC ? stripCSC(process.env) : process.env;
27+
if ((targetGroup === 'nsis') && !(childEnvironment.CSC_LINK || childEnvironment.WIN_CSC_LINK)) {
28+
throw new Error(`NSIS build requires CSC_LINK or WIN_CSC_LINK`);
29+
}
30+
const platformFlag = getPlatformFlag();
31+
const command = `electron-builder ${platformFlag} ${targetGroup}`;
32+
console.log(`running: ${command}`);
33+
spawnSync(command, {
34+
env: childEnvironment,
35+
shell: true,
36+
stdio: 'inherit'
37+
});
38+
};
39+
40+
const calculateTargets = function () {
41+
switch (process.platform) {
42+
case 'win32':
43+
// run in two passes so we can skip signing the appx
44+
return ['nsis', 'appx'];
45+
case 'darwin':
46+
// run in one pass for slightly better speed
47+
return ['dmg mas'];
48+
}
49+
throw new Error(`Could not determine targets for platform: ${process.platform}`);
50+
};
51+
52+
// TODO: allow user to specify targets? We could theoretically build NSIS on Mac, for example.
53+
const targets = calculateTargets();
54+
for (const targetGroup of targets) {
55+
runBuilder(targetGroup);
56+
}

0 commit comments

Comments
 (0)