|
| 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 | +'use strict'; |
| 7 | + |
| 8 | +import * as codesign from 'electron-osx-sign'; |
| 9 | +import * as path from 'path'; |
| 10 | +import * as util from '../lib/util'; |
| 11 | +import * as product from '../../product.json'; |
| 12 | + |
| 13 | +async function main(): Promise<void> { |
| 14 | + const buildDir = process.env['AGENT_BUILDDIRECTORY']; |
| 15 | + const tempDir = process.env['AGENT_TEMPDIRECTORY']; |
| 16 | + |
| 17 | + if (!buildDir) { |
| 18 | + throw new Error('$AGENT_BUILDDIRECTORY not set'); |
| 19 | + } |
| 20 | + |
| 21 | + if (!tempDir) { |
| 22 | + throw new Error('$AGENT_TEMPDIRECTORY not set'); |
| 23 | + } |
| 24 | + |
| 25 | + const baseDir = path.dirname(__dirname); |
| 26 | + const appRoot = path.join(buildDir, 'VSCode-darwin'); |
| 27 | + const appName = product.nameLong + '.app'; |
| 28 | + const appFrameworkPath = path.join(appRoot, appName, 'Contents', 'Frameworks'); |
| 29 | + const helperAppBaseName = product.nameShort; |
| 30 | + const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app'; |
| 31 | + const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app'; |
| 32 | + const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app'; |
| 33 | + |
| 34 | + const defaultOpts: codesign.SignOptions = { |
| 35 | + app: path.join(appRoot, appName), |
| 36 | + platform: 'darwin', |
| 37 | + entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'), |
| 38 | + 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'app-entitlements.plist'), |
| 39 | + hardenedRuntime: true, |
| 40 | + 'pre-auto-entitlements': false, |
| 41 | + 'pre-embed-provisioning-profile': false, |
| 42 | + keychain: path.join(tempDir, 'buildagent.keychain'), |
| 43 | + version: util.getElectronVersion(), |
| 44 | + identity: '99FM488X57', |
| 45 | + 'gatekeeper-assess': false |
| 46 | + }; |
| 47 | + |
| 48 | + const appOpts = { |
| 49 | + ...defaultOpts, |
| 50 | + // TODO(deepak1556): Incorrectly declared type in electron-osx-sign |
| 51 | + ignore: (filePath: string) => { |
| 52 | + return filePath.includes(gpuHelperAppName) || |
| 53 | + filePath.includes(pluginHelperAppName) || |
| 54 | + filePath.includes(rendererHelperAppName); |
| 55 | + } |
| 56 | + }; |
| 57 | + |
| 58 | + const gpuHelperOpts: codesign.SignOptions = { |
| 59 | + ...defaultOpts, |
| 60 | + app: path.join(appFrameworkPath, gpuHelperAppName), |
| 61 | + entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'), |
| 62 | + 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'), |
| 63 | + }; |
| 64 | + |
| 65 | + const pluginHelperOpts: codesign.SignOptions = { |
| 66 | + ...defaultOpts, |
| 67 | + app: path.join(appFrameworkPath, pluginHelperAppName), |
| 68 | + entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'), |
| 69 | + 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'), |
| 70 | + }; |
| 71 | + |
| 72 | + const rendererHelperOpts: codesign.SignOptions = { |
| 73 | + ...defaultOpts, |
| 74 | + app: path.join(appFrameworkPath, rendererHelperAppName), |
| 75 | + entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'), |
| 76 | + 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'), |
| 77 | + }; |
| 78 | + |
| 79 | + await codesign.signAsync(gpuHelperOpts); |
| 80 | + await codesign.signAsync(pluginHelperOpts); |
| 81 | + await codesign.signAsync(rendererHelperOpts); |
| 82 | + await codesign.signAsync(appOpts as any); |
| 83 | +} |
| 84 | + |
| 85 | +if (require.main === module) { |
| 86 | + main().catch(err => { |
| 87 | + console.error(err); |
| 88 | + process.exit(1); |
| 89 | + }); |
| 90 | +} |
0 commit comments