From fc5209723fb1f7c38d957b2784036a158b854662 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Thu, 22 May 2025 19:33:40 +0800 Subject: [PATCH] build: add win-sign script --- electron-builder.yml | 2 ++ scripts/win-sign.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 scripts/win-sign.js diff --git a/electron-builder.yml b/electron-builder.yml index b0d163009f..294335c36a 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -45,6 +45,8 @@ win: target: - target: nsis - target: portable + signtoolOptions: + sign: scripts/win-sign.js nsis: artifactName: ${productName}-${version}-${arch}-setup.${ext} shortcutName: ${productName} diff --git a/scripts/win-sign.js b/scripts/win-sign.js new file mode 100644 index 0000000000..f9b37c3aed --- /dev/null +++ b/scripts/win-sign.js @@ -0,0 +1,19 @@ +const { execSync } = require('child_process') + +exports.default = async function (configuration) { + if (process.env.WIN_SIGN) { + const { path } = configuration + if (configuration.path) { + try { + console.log('Start code signing...') + console.log('Signing file:', path) + const signCommand = `signtool sign /tr http://timestamp.comodoca.com /td sha256 /fd sha256 /a /v "${path}"` + execSync(signCommand, { stdio: 'inherit' }) + console.log('Code signing completed') + } catch (error) { + console.error('Code signing failed:', error) + throw error + } + } + } +}