Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/win32/codesign.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { $, usePwsh } from 'zx';
7
import { printBanner, spawnCodesignProcess, streamProcessOutputAndCheckResult } from '../common/codesign';
8
import { e } from '../common/publish';
9
10
async function main() {
11
usePwsh();
12
13
const arch = e('VSCODE_ARCH');
14
const esrpCliDLLPath = e('EsrpCliDllPath');
15
const codeSigningFolderPath = e('CodeSigningFolderPath');
16
17
// Start the code sign processes in parallel
18
// 1. Codesign executables and shared libraries
19
// 2. Codesign Powershell scripts
20
// 3. Codesign context menu appx package (insiders only)
21
const codesignTask1 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows', codeSigningFolderPath, '*.dll,*.exe,*.node');
22
const codesignTask2 = spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.ps1');
23
const codesignTask3 = process.env['VSCODE_QUALITY'] === 'insider'
24
? spawnCodesignProcess(esrpCliDLLPath, 'sign-windows-appx', codeSigningFolderPath, '*.appx')
25
: undefined;
26
27
// Codesign executables and shared libraries
28
printBanner('Codesign executables and shared libraries');
29
await streamProcessOutputAndCheckResult('Codesign executables and shared libraries', codesignTask1);
30
31
// Codesign Powershell scripts
32
printBanner('Codesign Powershell scripts');
33
await streamProcessOutputAndCheckResult('Codesign Powershell scripts', codesignTask2);
34
35
if (codesignTask3) {
36
// Codesign context menu appx package
37
printBanner('Codesign context menu appx package');
38
await streamProcessOutputAndCheckResult('Codesign context menu appx package', codesignTask3);
39
}
40
41
// Create build artifact directory
42
await $`New-Item -ItemType Directory -Path .build/win32-${arch} -Force`;
43
44
// Package client
45
if (process.env['BUILT_CLIENT']) {
46
// Product version
47
const version = await $`node -p "require('../VSCode-win32-${arch}/resources/app/package.json').version"`;
48
49
printBanner('Package client');
50
const clientArchivePath = `.build/win32-${arch}/VSCode-win32-${arch}-${version}.zip`;
51
await $`7z.exe a -tzip ${clientArchivePath} ../VSCode-win32-${arch}/* "-xr!CodeSignSummary*.md"`.pipe(process.stdout);
52
await $`7z.exe l ${clientArchivePath}`.pipe(process.stdout);
53
}
54
55
// Package server
56
if (process.env['BUILT_SERVER']) {
57
printBanner('Package server');
58
const serverArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}.zip`;
59
await $`7z.exe a -tzip ${serverArchivePath} ../vscode-server-win32-${arch}`.pipe(process.stdout);
60
await $`7z.exe l ${serverArchivePath}`.pipe(process.stdout);
61
}
62
63
// Package server (web)
64
if (process.env['BUILT_WEB']) {
65
printBanner('Package server (web)');
66
const webArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}-web.zip`;
67
await $`7z.exe a -tzip ${webArchivePath} ../vscode-server-win32-${arch}-web`.pipe(process.stdout);
68
await $`7z.exe l ${webArchivePath}`.pipe(process.stdout);
69
}
70
71
// Sign setup
72
if (process.env['BUILT_CLIENT']) {
73
printBanner('Sign setup packages (system, user)');
74
const task = $`npm exec -- npm-run-all -lp "gulp vscode-win32-${arch}-system-setup -- --sign" "gulp vscode-win32-${arch}-user-setup -- --sign"`;
75
await streamProcessOutputAndCheckResult('Sign setup packages (system, user)', task);
76
}
77
}
78
79
main().then(() => {
80
process.exit(0);
81
}, err => {
82
console.error(`ERROR: ${err}`);
83
process.exit(1);
84
});
85
86