Files
ForgeFlow/scripts/validate-signing-environment.mjs
T
NuklearRabbit 18f42621c2
ForgeFlow quality gate / quality (push) Canceled after 0s
feat: harden release signing and coverage gate
2026-07-29 22:54:51 +02:00

18 lines
1.5 KiB
JavaScript

const signedRelease = process.env.FORGEFLOW_SIGNED_RELEASE === "1";
const publisher = String(process.env.FORGEFLOW_EXPECTED_PUBLISHER || "").trim();
const classicCertificate = String(process.env.WIN_CSC_LINK || process.env.CSC_LINK || "").trim();
const azureNames = ["AZURE_TENANT_ID", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", "FORGEFLOW_AZURE_SIGNING_ENDPOINT", "FORGEFLOW_AZURE_SIGNING_ACCOUNT", "FORGEFLOW_AZURE_CERTIFICATE_PROFILE"];
const azureValues = azureNames.map((name) => String(process.env[name] || "").trim());
const azure = azureValues.every(Boolean);
const partialAzure = azureValues.some(Boolean) && !azure;
if (!signedRelease) throw new Error("FORGEFLOW_SIGNED_RELEASE=1 is required for the production signing build.");
if (!/^CN=.+/i.test(publisher)) throw new Error("FORGEFLOW_EXPECTED_PUBLISHER must be the exact certificate subject beginning with CN=.");
if (partialAzure) throw new Error(`Azure Artifact Signing is incomplete. Configure: ${azureNames.filter((_, index) => !azureValues[index]).join(", ")}.`);
if (!classicCertificate && !azure) throw new Error("Configure WIN_CSC_LINK/CSC_LINK or all Azure Artifact Signing credentials before building a signed release.");
if (classicCertificate && !String(process.env.WIN_CSC_KEY_PASSWORD || process.env.CSC_KEY_PASSWORD || "").trim()) {
throw new Error("WIN_CSC_KEY_PASSWORD or CSC_KEY_PASSWORD is required for classic certificate signing.");
}
console.log(`Production ${azure ? "Azure Artifact Signing" : "classic certificate"} environment accepted for exact publisher ${publisher}.`);