Skip to content

Commit

Permalink
Merge pull request #5148 from jandubois/signtool-description
Browse files Browse the repository at this point in the history
Add a description to the signtool command
  • Loading branch information
jandubois authored Jul 15, 2023
2 parents d1d52e1 + ff706c6 commit 539f8ab
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/lib/sign-win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ interface ElectronBuilderConfiguration {
win?: Partial<typeof DEFAULT_WINDOWS_CONFIG & typeof REQUIRED_WINDOWS_CONFIG>;
}

async function getVersion() {
const version = JSON.parse(await fs.promises.readFile('package.json', 'utf-8'))['version'];

if (!version) {
throw new Error("Can't find the version field in package.json");
}

return version;
}

export async function sign(workDir: string) {
const certFingerprint = process.env.CSC_FINGERPRINT ?? '';
const certPassword = process.env.CSC_KEY_PASSWORD ?? '';
Expand All @@ -61,6 +71,7 @@ export async function sign(workDir: string) {

const configText = await fs.promises.readFile(path.join(unpackedDir, 'electron-builder.yml'), 'utf-8');
const config = yaml.parse(configText) as ElectronBuilderConfiguration;
const versionedAppName = `Rancher Desktop ${ await getVersion() }`;

config.win ??= {};
defaults(config.win, DEFAULT_WINDOWS_CONFIG);
Expand All @@ -76,6 +87,7 @@ export async function sign(workDir: string) {
'/td', 'SHA256',
'/tr', config.win.rfc3161TimeStampServer as string,
'/du', 'https://rancherdesktop.io',
'/d', versionedAppName,
];

if (certPassword.length > 0) {
Expand All @@ -100,6 +112,7 @@ export async function sign(workDir: string) {
async function buildWiX(workDir: string, unpackedDir: string, config: ElectronBuilderConfiguration) {
const buildInstaller = (await import('./installer-win32')).default;
const installerPath = await buildInstaller(workDir, unpackedDir);
const versionedAppName = `Rancher Desktop ${ await getVersion() }`;

if (!config.win?.certificateSha1) {
throw new Error(`Assertion error: certificate fingerprint not set`);
Expand All @@ -114,6 +127,7 @@ async function buildWiX(workDir: string, unpackedDir: string, config: ElectronBu
'/td', 'SHA256',
'/tr', config.win.rfc3161TimeStampServer as string,
'/du', 'https://rancherdesktop.io',
'/d', versionedAppName,
installerPath,
];

Expand Down

0 comments on commit 539f8ab

Please sign in to comment.