Files
vscode/build/azure-pipelines/win32/codesign.ts
Matt Bierner 2648263d3e Run our build scripts directly as typescript (#277567)
* Run our build scripts directly as typescript #277567

Follow up on #276864
For #277526

* Remove a few more ts-node references

* Fix linux and script reference

* Remove `_build-script` ref

* Fix script missing closing quote

* use type only import

* Fix export

* Make sure to run copy-policy-dto

* Make sure we run the copy-policy-dto script

* Enable `verbatimModuleSyntax`

* Pipelines fixes

* Try adding explicit ext to path

* Fix bad edit

* Revert extra `--`

---------

Co-authored-by: João Moreno <joaomoreno@users.noreply.github.com>
2025-11-21 14:56:00 +01:00

85 lines
3.6 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $, usePwsh } from 'zx';
import { printBanner, spawnCodesignProcess, streamProcessOutputAndCheckResult } from '../common/codesign.ts';
import { e } from '../common/publish.ts';
async function main() {
usePwsh();
const arch = e('VSCODE_ARCH');
const esrpCliDLLPath = e('EsrpCliDllPath');
const codeSigningFolderPath = e('CodeSigningFolderPath');
// Start the code sign processes in parallel
// 1. Codesign executables and shared libraries
// 2. Codesign Powershell scripts
// 3. Codesign context menu appx package (insiders only)
const codesignTask1 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows', codeSigningFolderPath, '*.dll,*.exe,*.node');
const codesignTask2 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.ps1');
const codesignTask3 = process.env['VSCODE_QUALITY'] === 'insider'
? spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.appx')
: undefined;
// Codesign executables and shared libraries
printBanner('Codesign executables and shared libraries');
await streamProcessOutputAndCheckResult('Codesign executables and shared libraries', codesignTask1);
// Codesign Powershell scripts
printBanner('Codesign Powershell scripts');
await streamProcessOutputAndCheckResult('Codesign Powershell scripts', codesignTask2);
if (codesignTask3) {
// Codesign context menu appx package
printBanner('Codesign context menu appx package');
await streamProcessOutputAndCheckResult('Codesign context menu appx package', codesignTask3);
}
// Create build artifact directory
await $`New-Item -ItemType Directory -Path .build/win32-${arch} -Force`;
// Package client
if (process.env['BUILT_CLIENT']) {
// Product version
const version = await $`node -p "require('../VSCode-win32-${arch}/resources/app/package.json').version"`;
printBanner('Package client');
const clientArchivePath = `.build/win32-${arch}/VSCode-win32-${arch}-${version}.zip`;
await $`7z.exe a -tzip ${clientArchivePath} ../VSCode-win32-${arch}/* "-xr!CodeSignSummary*.md"`.pipe(process.stdout);
await $`7z.exe l ${clientArchivePath}`.pipe(process.stdout);
}
// Package server
if (process.env['BUILT_SERVER']) {
printBanner('Package server');
const serverArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}.zip`;
await $`7z.exe a -tzip ${serverArchivePath} ../vscode-server-win32-${arch}`.pipe(process.stdout);
await $`7z.exe l ${serverArchivePath}`.pipe(process.stdout);
}
// Package server (web)
if (process.env['BUILT_WEB']) {
printBanner('Package server (web)');
const webArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}-web.zip`;
await $`7z.exe a -tzip ${webArchivePath} ../vscode-server-win32-${arch}-web`.pipe(process.stdout);
await $`7z.exe l ${webArchivePath}`.pipe(process.stdout);
}
// Sign setup
if (process.env['BUILT_CLIENT']) {
printBanner('Sign setup packages (system, user)');
const task = $`npm exec -- npm-run-all -lp "gulp vscode-win32-${arch}-system-setup -- --sign" "gulp vscode-win32-${arch}-user-setup -- --sign"`;
await streamProcessOutputAndCheckResult('Sign setup packages (system, user)', task);
}
}
main().then(() => {
process.exit(0);
}, err => {
console.error(`ERROR: ${err}`);
process.exit(1);
});