Engineering - refactor codesign scripts (#246459)

* Engineering - consolidate codesign scripts

* Try using a script task

* Switch back to old syntax

* Bump deemon
This commit is contained in:
Ladislau Szomoru
2025-04-14 08:13:45 +01:00
committed by GitHub
parent 956efd2c00
commit 1799c2beaa
11 changed files with 140 additions and 176 deletions

View File

@@ -3,49 +3,25 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $, ProcessPromise } from 'zx';
import { printBanner, spawnCodesignProcess, streamProcessOutputAndCheckResult } from '../common/codesign';
import { e } from '../common/publish';
function printBanner(title: string) {
title = `${title} (${new Date().toISOString()})`;
console.log('\n');
console.log('#'.repeat(75));
console.log(`# ${title.padEnd(71)} #`);
console.log('#'.repeat(75));
console.log('\n');
}
async function streamTaskOutputAndCheckResult(name: string, promise: ProcessPromise): Promise<void> {
const result = await promise.pipe(process.stdout);
if (result.ok) {
console.log(`\n${name} completed successfully. Duration: ${result.duration} ms`);
return;
}
throw new Error(`${name} failed: ${result.stderr}`);
}
function sign(esrpCliDLLPath: string, type: 'sign-pgp', folder: string, glob: string): ProcessPromise {
return $`node build/azure-pipelines/common/sign ${esrpCliDLLPath} ${type} ${folder} ${glob}`;
}
async function main() {
const esrpCliDLLPath = e('EsrpCliDllPath');
// Start the code sign processes in parallel
// 1. Codesign deb package
// 2. Codesign rpm package
const codesignTask1 = sign(esrpCliDLLPath, 'sign-pgp', '.build/linux/deb', '*.deb');
const codesignTask2 = sign(esrpCliDLLPath, 'sign-pgp', '.build/linux/rpm', '*.rpm');
const codesignTask1 = spawnCodesignProcess(esrpCliDLLPath, 'sign-pgp', '.build/linux/deb', '*.deb');
const codesignTask2 = spawnCodesignProcess(esrpCliDLLPath, 'sign-pgp', '.build/linux/rpm', '*.rpm');
// Codesign deb package
printBanner('Codesign deb package');
await streamTaskOutputAndCheckResult('Codesign deb package', codesignTask1);
await streamProcessOutputAndCheckResult('Codesign deb package', codesignTask1);
// Codesign rpm package
printBanner('Codesign rpm package');
await streamTaskOutputAndCheckResult('Codesign rpm package', codesignTask2);
await streamProcessOutputAndCheckResult('Codesign rpm package', codesignTask2);
}
main().then(() => {