-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Sign windows builds via remote key storage (#15718)
Integrates code signing with a key stored in digicert one to app build workflows. There are a couple caveats: - You can do this locally if you have a windows machine and if you have the right accounts and permissions. Read: you basically can't do this locally - Digicert for some reason charges per signature. We sign a lot of stuff. Therefore, we are only going to produce signed windows builds for releases and if a dev really needs to by pushing a branch that has "as-release" in it (in the same way we only do app builds if you push a branch that has app-build in it - so building and signing both windows apps would require a branch that has app-build-both-as-release in it) - This just doesn't work at all with electron-builder, and they don't seem to want to change things to fix it; specifically, you can only configure e-b to pass along a key link and a password, and you basically can't do that anymore. So we have to have a (thankfully simple) custom sign script. Closes RDEVOPS-128 ## to leave draft - [x] this produces a signed installer that passes smartscreen - [x] this only does that on branches with the right kinds of names
- Loading branch information
Showing
3 changed files
with
134 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// from https://github.com/electron-userland/electron-builder/issues/7605 | ||
|
||
'use strict' | ||
|
||
const { execSync } = require('node:child_process') | ||
|
||
exports.default = async configuration => { | ||
const signCmd = `smctl sign --keypair-alias="${String( | ||
process.env.SM_KEYPAIR_ALIAS | ||
)}" --input "${String(configuration.path)}" --certificate="${String( | ||
process.env.WINDOWS_CSC_FILEPATH | ||
)}" --exit-non-zero-on-fail --failfast --verbose` | ||
console.log(signCmd) | ||
try { | ||
const signProcess = execSync(signCmd, { | ||
stdio: 'pipe', | ||
}) | ||
console.log(`Sign success!`) | ||
console.log( | ||
`Sign stdout: ${signProcess?.stdout?.toString() ?? '<no output>'}` | ||
) | ||
console.log( | ||
`Sign stderr: ${signProcess?.stderr?.toString() ?? '<no output>'}` | ||
) | ||
console.log(`Sign code: ${signProcess.code}`) | ||
} catch (err) { | ||
console.error(`Exception running sign: ${err.status}! | ||
Process stdout: | ||
${err?.stdout?.toString() ?? '<no output>'} | ||
------------- | ||
Process stderr: | ||
${err?.stdout?.toString() ?? '<no output>'} | ||
------------- | ||
`) | ||
throw err | ||
} | ||
const verifyCmd = `smctl sign verify --fingerprint="${String( | ||
process.env.SM_CODE_SIGNING_CERT_SHA1_HASH | ||
)}" --input="${String(configuration.path)}" --verbose` | ||
console.log(verifyCmd) | ||
try { | ||
const verifyProcess = execSync(verifyCmd, { stdio: 'pipe' }) | ||
console.log(`Verify success!`) | ||
console.log( | ||
`Verify stdout: ${verifyProcess?.stdout?.toString() ?? '<no output>'}` | ||
) | ||
console.log( | ||
`Verify stderr: ${verifyProcess?.stderr?.toString() ?? '<no output>'}` | ||
) | ||
} catch (err) { | ||
console.error(` | ||
Exception running verification: ${err.status}! | ||
Process stdout: | ||
${err?.stdout?.toString() ?? '<no output>'} | ||
-------------- | ||
Process stderr: | ||
${err?.stderr?.toString() ?? '<no output>'} | ||
-------------- | ||
`) | ||
throw err | ||
} | ||
} |