Unverified 提交 05a6b7b0 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

enable debug logging for windows sign (#2034)

<!-- CURSOR_SUMMARY --> > [!NOTE] > Improves observability of Windows signing during releases. > > - Enable Electron Forge debug output in the workflow by setting `DEBUG="@electron/*"` during `Publish app` > - Turn on `windowsSign.debug` in `forge.config.ts` > - Add detailed, redacted logging and error handling to `scripts/windows-sign-hook.js` (logs inputs, command, success/failure; still only signs `dyad.exe`) > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bfdbc12a7a0e5a5eb0810a3303e732c6ad0a4eef. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Enable verbose debugging for Windows code signing to make CI signing issues easier to diagnose. Adds detailed logs in the signing hook and enables Electron Forge debug output during release. - **New Features** - Set DEBUG="@electron/*" in the release workflow to capture Forge/Squirrel logs. - Enable windowsSign.debug in forge.config. - Add verbose logging and error handling in windows-sign-hook (inputs, command, success/failure). <sup>Written for commit bfdbc12a7a0e5a5eb0810a3303e732c6ad0a4eef. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
上级 5147d767
...@@ -65,6 +65,7 @@ jobs: ...@@ -65,6 +65,7 @@ jobs:
# Publish (all platforms) # Publish (all platforms)
- name: Publish app - name: Publish app
env: env:
DEBUG: "@electron/*"
NODE_OPTIONS: "--max-old-space-size=4096" NODE_OPTIONS: "--max-old-space-size=4096"
SM_CODE_SIGNING_CERT_SHA1_HASH: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} SM_CODE_SIGNING_CERT_SHA1_HASH: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
......
...@@ -88,6 +88,7 @@ const config: ForgeConfig = { ...@@ -88,6 +88,7 @@ const config: ForgeConfig = {
makers: [ makers: [
new MakerSquirrel({ new MakerSquirrel({
windowsSign: { windowsSign: {
debug: true,
hookModulePath: path.join(__dirname, "scripts", "windows-sign-hook.js"), hookModulePath: path.join(__dirname, "scripts", "windows-sign-hook.js"),
}, },
}), }),
......
const { execSync } = require("child_process"); const { execSync } = require("child_process");
const path = require("path"); const path = require("path");
// Path to signtool.exe bundled with electron-winstaller
// On GitHub Actions, this is the full path:
// D:\a\dyad\dyad\node_modules\electron-winstaller\vendor\signtool.exe
const SIGNTOOL_PATH = path.join( const SIGNTOOL_PATH = path.join(
__dirname, __dirname,
"..", "..",
...@@ -13,19 +10,32 @@ const SIGNTOOL_PATH = path.join( ...@@ -13,19 +10,32 @@ const SIGNTOOL_PATH = path.join(
"signtool.exe", "signtool.exe",
); );
/**
* Custom hook function for Windows code signing.
* Only signs dyad.exe, skips all other files.
* @param {string} filePath - Path to the file to sign
*/
module.exports = function (filePath) { module.exports = function (filePath) {
console.log(`[windows-sign-hook] Called with: ${filePath}`);
console.log(`[windows-sign-hook] SIGNTOOL_PATH: ${SIGNTOOL_PATH}`);
console.log(
`[windows-sign-hook] SM_CODE_SIGNING_CERT_SHA1_HASH: ${process.env.SM_CODE_SIGNING_CERT_SHA1_HASH ? "SET" : "NOT SET"}`,
);
const fileName = path.basename(filePath).toLowerCase(); const fileName = path.basename(filePath).toLowerCase();
// Only sign dyad.exe, skip all other files
if (fileName !== "dyad.exe") { if (fileName !== "dyad.exe") {
console.log(`[windows-sign-hook] Skipping: ${fileName}`);
return; return;
} }
const signParams = `/sha1 ${process.env.SM_CODE_SIGNING_CERT_SHA1_HASH} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256`;
execSync(`"${SIGNTOOL_PATH}" sign ${signParams} "${filePath}"`, { console.log(`[windows-sign-hook] Signing: ${fileName}`);
stdio: "inherit", const certHash = process.env.SM_CODE_SIGNING_CERT_SHA1_HASH;
}); const signParams = `/sha1 ${certHash} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256`;
const cmd = `"${SIGNTOOL_PATH}" sign ${signParams} "${filePath}"`;
const redactedSignParams = `/sha1 ${certHash ? "[REDACTED]" : "[NOT SET]"} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256`;
const redactedCmd = `"${SIGNTOOL_PATH}" sign ${redactedSignParams} "${filePath}"`;
console.log(`[windows-sign-hook] Command: ${redactedCmd}`);
try {
execSync(cmd, { stdio: "inherit" });
console.log(`[windows-sign-hook] Signing successful`);
} catch (error) {
console.error(`[windows-sign-hook] Signing failed:`, error);
throw error;
}
}; };
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论