type Platform = "macos" | "windows" | "linux"; type Step = { id: string; tool: string; args: string[]; executes: false; }; const SIGN = "codesign"; const NOTARY = "notarytool"; const STAPLE = "stapler"; const WINSIGN = "signtool"; const GPG = "gpg"; function plan(platform: Platform): Step[] { if (platform === "macos") { return [ { id: "sign", tool: SIGN, args: [ "--force", "--options", "runtime", "--timestamp", "--sign", "Developer ID Application: ", "MyApp.app", ], executes: false, }, { id: "notarize", tool: NOTARY, args: ["submit", "MyApp.zip", "--wait"], executes: false, }, { id: "staple", tool: STAPLE, args: ["staple", "MyApp.app"], executes: false, }, ]; } if (platform === "windows") { return [ { id: "sign", tool: WINSIGN, args: [ "sign", "/fd", "SHA256", "/tr", "https://timestamp.example", "/td", "SHA256", "MyApp-Setup.exe", ], executes: false, }, { id: "verify", tool: WINSIGN, args: ["verify", "/pa", "MyApp-Setup.exe"], executes: false, }, ]; } return [ { id: "sign", tool: GPG, args: ["--armor", "--detach-sign", "MyApp.AppImage"], executes: false, }, { id: "verify", tool: GPG, args: ["--verify", "MyApp.AppImage.asc", "MyApp.AppImage"], executes: false, }, ]; } const mac = plan("macos"); const win = plan("windows"); const linux = plan("linux"); const macRoles = mac.map((step) => step.id).join(","); const winRoles = win.map((step) => step.id).join(","); const allDryRun = [...mac, ...win, ...linux].every( (step) => step.executes === false, ); const ok = macRoles === "sign,notarize,staple" && mac.some((step) => step.args.includes("runtime")) && mac.some((step) => step.args.includes("--timestamp")) && mac.some((step) => step.args.includes("--wait")) && winRoles === "sign,verify" && win.some((step) => step.args.includes("/tr")) && win.some((step) => step.args.includes("/pa")) && linux.every((step) => step.tool === GPG) && allDryRun; console.log( JSON.stringify({ evt: "smoke", ok, macRoles, winRoles, allDryRun, commands: [...mac, ...win, ...linux].map((step) => [step.tool, ...step.args].join(" "), ), }), );