Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/win32/codesign.ts
5319 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.ts';
8
import { e } from '../common/publish.ts';
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'] !== 'exploration'
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
printBanner('Package client');
47
const clientArchivePath = `.build/win32-${arch}/VSCode-win32-${arch}.zip`;
48
await $`7z.exe a -tzip ${clientArchivePath} ../VSCode-win32-${arch}/* "-xr!CodeSignSummary*.md"`.pipe(process.stdout);
49
await $`7z.exe l ${clientArchivePath}`.pipe(process.stdout);
50
}
51
52
// Package server
53
if (process.env['BUILT_SERVER']) {
54
printBanner('Package server');
55
const serverArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}.zip`;
56
await $`7z.exe a -tzip ${serverArchivePath} ../vscode-server-win32-${arch}`.pipe(process.stdout);
57
await $`7z.exe l ${serverArchivePath}`.pipe(process.stdout);
58
}
59
60
// Package server (web)
61
if (process.env['BUILT_WEB']) {
62
printBanner('Package server (web)');
63
const webArchivePath = `.build/win32-${arch}/vscode-server-win32-${arch}-web.zip`;
64
await $`7z.exe a -tzip ${webArchivePath} ../vscode-server-win32-${arch}-web`.pipe(process.stdout);
65
await $`7z.exe l ${webArchivePath}`.pipe(process.stdout);
66
}
67
68
// Sign setup
69
if (process.env['BUILT_CLIENT']) {
70
printBanner('Sign setup packages (system, user)');
71
const task = $`npm exec -- npm-run-all2 -lp "gulp vscode-win32-${arch}-system-setup -- --sign" "gulp vscode-win32-${arch}-user-setup -- --sign"`;
72
await streamProcessOutputAndCheckResult('Sign setup packages (system, user)', task);
73
}
74
}
75
76
main().then(() => {
77
process.exit(0);
78
}, err => {
79
console.error(`ERROR: ${err}`);
80
process.exit(1);
81
});
82
83