Path: blob/main/build/azure-pipelines/win32/codesign.ts
5319 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { $, usePwsh } from 'zx';6import { printBanner, spawnCodesignProcess, streamProcessOutputAndCheckResult } from '../common/codesign.ts';7import { e } from '../common/publish.ts';89async function main() {10usePwsh();1112const arch = e('VSCODE_ARCH');13const esrpCliDLLPath = e('EsrpCliDllPath');14const codeSigningFolderPath = e('CodeSigningFolderPath');1516// Start the code sign processes in parallel17// 1. Codesign executables and shared libraries18// 2. Codesign Powershell scripts19// 3. Codesign context menu appx package (insiders only)20const codesignTask1 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows', codeSigningFolderPath, '*.dll,*.exe,*.node');21const codesignTask2 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.ps1');22const codesignTask3 = process.env['VSCODE_QUALITY'] !== 'exploration'23? spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.appx')24: undefined;2526// Codesign executables and shared libraries27printBanner('Codesign executables and shared libraries');28await streamProcessOutputAndCheckResult('Codesign executables and shared libraries', codesignTask1);2930// Codesign Powershell scripts31printBanner('Codesign Powershell scripts');32await streamProcessOutputAndCheckResult('Codesign Powershell scripts', codesignTask2);3334if (codesignTask3) {35// Codesign context menu appx package36printBanner('Codesign context menu appx package');37await streamProcessOutputAndCheckResult('Codesign context menu appx package', codesignTask3);38}3940// Create build artifact directory41await $`New-Item -ItemType Directory -Path .build/win32-${arch} -Force`;4243// Package client44if (process.env['BUILT_CLIENT']) {45printBanner('Package client');46const clientArchivePath = `.build/win32-${arch}/VSCode-win32-${arch}.zip`;47await $`7z.exe a -tzip ${clientArchivePath} ../VSCode-win32-${arch}/* "-xr!CodeSignSummary*.md"`.pipe(process.stdout);48await $`7z.exe l ${clientArchivePath}`.pipe(process.stdout);49}5051// Package server52if (process.env['BUILT_SERVER']) {53printBanner('Package server');54const serverArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}.zip`;55await $`7z.exe a -tzip ${serverArchivePath} ../vscode-server-win32-${arch}`.pipe(process.stdout);56await $`7z.exe l ${serverArchivePath}`.pipe(process.stdout);57}5859// Package server (web)60if (process.env['BUILT_WEB']) {61printBanner('Package server (web)');62const webArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}-web.zip`;63await $`7z.exe a -tzip ${webArchivePath} ../vscode-server-win32-${arch}-web`.pipe(process.stdout);64await $`7z.exe l ${webArchivePath}`.pipe(process.stdout);65}6667// Sign setup68if (process.env['BUILT_CLIENT']) {69printBanner('Sign setup packages (system, user)');70const task = $`npm exec -- npm-run-all2 -lp "gulp vscode-win32-${arch}-system-setup -- --sign" "gulp vscode-win32-${arch}-user-setup -- --sign"`;71await streamProcessOutputAndCheckResult('Sign setup packages (system, user)', task);72}73}7475main().then(() => {76process.exit(0);77}, err => {78console.error(`ERROR: ${err}`);79process.exit(1);80});818283