Path: blob/main/build/azure-pipelines/win32/codesign.ts
3520 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';7import { e } from '../common/publish';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'] === 'insider'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']) {45// Product version46const version = await $`node -p "require('../VSCode-win32-${arch}/resources/app/package.json').version"`;4748printBanner('Package client');49const clientArchivePath = `.build/win32-${arch}/VSCode-win32-${arch}-${version}.zip`;50await $`7z.exe a -tzip ${clientArchivePath} ../VSCode-win32-${arch}/* "-xr!CodeSignSummary*.md"`.pipe(process.stdout);51await $`7z.exe l ${clientArchivePath}`.pipe(process.stdout);52}5354// Package server55if (process.env['BUILT_SERVER']) {56printBanner('Package server');57const serverArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}.zip`;58await $`7z.exe a -tzip ${serverArchivePath} ../vscode-server-win32-${arch}`.pipe(process.stdout);59await $`7z.exe l ${serverArchivePath}`.pipe(process.stdout);60}6162// Package server (web)63if (process.env['BUILT_WEB']) {64printBanner('Package server (web)');65const webArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}-web.zip`;66await $`7z.exe a -tzip ${webArchivePath} ../vscode-server-win32-${arch}-web`.pipe(process.stdout);67await $`7z.exe l ${webArchivePath}`.pipe(process.stdout);68}6970// Sign setup71if (process.env['BUILT_CLIENT']) {72printBanner('Sign setup packages (system, user)');73const task = $`npm exec -- npm-run-all -lp "gulp vscode-win32-${arch}-system-setup -- --sign" "gulp vscode-win32-${arch}-user-setup -- --sign"`;74await streamProcessOutputAndCheckResult('Sign setup packages (system, user)', task);75}76}7778main().then(() => {79process.exit(0);80}, err => {81console.error(`ERROR: ${err}`);82process.exit(1);83});848586