|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +parameters: |
| 5 | + - name: prerelease |
| 6 | + type: boolean |
| 7 | + default: false |
| 8 | + |
| 9 | +jobs: |
| 10 | + - job: Build |
| 11 | + pool: |
| 12 | + name: VSEngSS-MicroBuild2019-1ES |
| 13 | + variables: |
| 14 | + # MicroBuild requires TeamName to be set. |
| 15 | + TeamName: C++ Cross Platform and Cloud |
| 16 | + steps: |
| 17 | + - task: MicroBuildSigningPlugin@3 |
| 18 | + displayName: Install MicroBuild Signing |
| 19 | + inputs: |
| 20 | + signType: $(SignType) |
| 21 | + zipSources: false |
| 22 | + # MicroBuild signing will always fail on public PRs. |
| 23 | + condition: ne(variables['Build.Reason'], 'PullRequest') |
| 24 | + |
| 25 | + # Run these scanners first so that they don't detect issues in dependencies. |
| 26 | + # Failures won't break the build until "Check for compliance errors" step. |
| 27 | + - task: CredScan@2 |
| 28 | + displayName: Run CredScan |
| 29 | + inputs: |
| 30 | + toolMajorVersion: V2 |
| 31 | + - task: PoliCheck@1 |
| 32 | + displayName: Run PoliCheck |
| 33 | + inputs: |
| 34 | + targetType: F |
| 35 | + targetArgument: $(Build.SourcesDirectory) |
| 36 | + |
| 37 | + # Node 14 matches the version of Node used by VS Code when this was written, |
| 38 | + # but it should be updated when VS Code updates its Node version. |
| 39 | + - task: NodeTool@0 |
| 40 | + displayName: Use Node 16.x |
| 41 | + inputs: |
| 42 | + versionSpec: 16.x |
| 43 | + |
| 44 | + # Override the patch version if this is a pre-release build. |
| 45 | + - ${{ if parameters.prerelease }}: |
| 46 | + - pwsh: node -e "p=require('./package.json');p.version=p.version.replace(/\.\d+$/,'.'+$(Build.BuildNumber));require('fs').writeFileSync('./package.json',JSON.stringify(p,undefined,2))" |
| 47 | + |
| 48 | + - script: npm install --global gulp node-gyp @vscode/vsce |
| 49 | + displayName: Install global dependencies |
| 50 | + - script: npm install |
| 51 | + displayName: Install project dependencies |
| 52 | + |
| 53 | + - task: ComponentGovernanceComponentDetection@0 |
| 54 | + displayName: Detect components |
| 55 | + - task: notice@0 |
| 56 | + displayName: Generate NOTICE file |
| 57 | + inputs: |
| 58 | + outputfile: $(Build.SourcesDirectory)/NOTICE.txt |
| 59 | + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) |
| 60 | + |
| 61 | + - script: gulp tslint |
| 62 | + displayName: Check for linting errors |
| 63 | + - script: gulp genAikey |
| 64 | + displayName: Use production AI key |
| 65 | + condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags')) |
| 66 | + # Pack the extension now even though it's unsigned so that we ignore files |
| 67 | + # from .vscodeignore. This will reduce load on the signing server later and |
| 68 | + # ensure we only attempt to sign shipping files. |
| 69 | + - ${{ if parameters.prerelease }}: |
| 70 | + - script: node build/package.js --pre-release |
| 71 | + displayName: Build and pack extension |
| 72 | + - ${{ else }}: |
| 73 | + - script: node build/package.js |
| 74 | + displayName: Build and pack extension |
| 75 | + |
| 76 | + # Extract the VSIXes, sign what we can, then pack it back up and publish it. |
| 77 | + - pwsh: | |
| 78 | + $path = Join-Path $Env:TEMP "7z-installer.exe" |
| 79 | + Invoke-WebRequest https://www.7-zip.org/a/7z2201-x64.exe -OutFile $path |
| 80 | + Start-Process -FilePath $path -Args "/S" -Verb RunAs -Wait |
| 81 | + Remove-Item $path |
| 82 | + Echo "##vso[task.prependpath]$Env:PROGRAMFILES\7-Zip\" |
| 83 | + displayName: Install 7zip |
| 84 | + - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z x $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$($_.BaseName) } |
| 85 | + displayName: Extract extension for signing |
| 86 | + - task: NuGetToolInstaller@1 |
| 87 | + displayName: Install NuGet |
| 88 | + - task: NuGetAuthenticate@0 |
| 89 | + displayName: Authenticate NuGet |
| 90 | + - script: nuget restore .\build\SignFiles.proj -PackagesDirectory .\build\packages |
| 91 | + displayName: Restore MicroBuild Core |
| 92 | + # MicroBuild signing will always fail on public PRs. |
| 93 | + condition: ne(variables['Build.Reason'], 'PullRequest') |
| 94 | + - task: MSBuild@1 |
| 95 | + displayName: Sign files |
| 96 | + inputs: |
| 97 | + solution: .\build\SignFiles.proj |
| 98 | + msbuildArguments: /p:SignType=$(SignType) |
| 99 | + # MicroBuild signing will always fail on public PRs. |
| 100 | + condition: ne(variables['Build.Reason'], 'PullRequest') |
| 101 | + - pwsh: | |
| 102 | + Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") ($_.FullName + "\*") -tzip } |
| 103 | + New-Item -Path $(Build.StagingDirectory)\vscode-arduino\vsix -ItemType Directory |
| 104 | + Get-Item $(Build.StagingDirectory)\vscode-arduino\*.vsix | Move-Item -Destination $(Build.StagingDirectory)\vscode-arduino\vsix |
| 105 | + displayName: Pack signed files |
| 106 | + - task: MSBuild@1 |
| 107 | + displayName: Sign VSIXes |
| 108 | + inputs: |
| 109 | + solution: .\build\SignVsix.proj |
| 110 | + msbuildArguments: /p:SignType=$(SignType) |
| 111 | + # MicroBuild signing will always fail on public PRs. |
| 112 | + condition: ne(variables['Build.Reason'], 'PullRequest') |
| 113 | + - publish: $(Build.StagingDirectory)\vscode-arduino\vsix |
| 114 | + artifact: extension-vsixes |
| 115 | + displayName: Publish extension VSIXes as artifact |
| 116 | + |
| 117 | + # Install the Arduino IDE and run tests. |
| 118 | + - script: curl -LO https://downloads.arduino.cc/arduino-1.8.19-windows.zip |
| 119 | + displayName: Download Arduino IDE |
| 120 | + - script: >- |
| 121 | + node build/checkHash.js arduino-1.8.19-windows.zip |
| 122 | + c704a821089eab2588f1deae775916219b1517febd1dd574ff29958dca873945 |
| 123 | + displayName: Verify Arduino IDE |
| 124 | + - task: ExtractFiles@1 |
| 125 | + displayName: Extract Arduino IDE |
| 126 | + inputs: |
| 127 | + archiveFilePatterns: arduino-1.8.19-windows.zip |
| 128 | + destinationFolder: arduino-ide |
| 129 | + - script: "echo ##vso[task.prependpath]$(Build.SourcesDirectory)\\arduino-ide\\arduino-1.8.19" |
| 130 | + displayName: Add Arduino IDE to PATH |
| 131 | + - script: npm test --silent |
| 132 | + displayName: Run tests |
| 133 | + |
| 134 | + - task: PostAnalysis@1 |
| 135 | + displayName: Check for compliance errors |
| 136 | + # To avoid spirious warnings about missing logs, explicitly declare what we scanned. |
| 137 | + inputs: |
| 138 | + CredScan: true |
| 139 | + PoliCheck: true |
| 140 | + |
| 141 | + # Trust Services Automation (TSA) can automatically open bugs for compliance issues. |
| 142 | + # https://www.1eswiki.com/wiki/Trust_Services_Automation_(TSA) |
| 143 | + - task: TSAUpload@1 |
| 144 | + displayName: Upload logs to TSA |
| 145 | + inputs: |
| 146 | + tsaVersion: TsaV2 |
| 147 | + codebase: NewOrUpdate |
| 148 | + codeBaseName: vscode-arduino |
| 149 | + notificationAlias: [email protected] |
| 150 | + instanceUrlForTsaV2: DEVDIV |
| 151 | + projectNameDEVDIV: DevDiv |
| 152 | + areaPath: DevDiv\Cpp Developer Experience\Cross Platform\Embedded |
| 153 | + iterationPath: DevDiv |
| 154 | + # To avoid spurious warnings about missing logs, explicitly declare what we don't upload. |
| 155 | + uploadAPIScan: false |
| 156 | + uploadBinSkim: false |
| 157 | + uploadFortifySCA: false |
| 158 | + uploadFxCop: false |
| 159 | + uploadModernCop: false |
| 160 | + uploadPREfast: false |
| 161 | + uploadRoslyn: false |
| 162 | + uploadTSLint: false |
| 163 | + # Don't open bugs for PR builds |
| 164 | + condition: ne(variables['Build.Reason'], 'PullRequest') |
| 165 | + |
| 166 | + - task: GitHubRelease@0 |
| 167 | + displayName: Publish to GitHub |
| 168 | + inputs: |
| 169 | + gitHubConnection: embeddedbot |
| 170 | + repositoryName: microsoft/vscode-arduino |
| 171 | + action: create |
| 172 | + target: $(Build.SourceVersion) |
| 173 | + tagSource: auto |
| 174 | + assets: $(Build.StagingDirectory)\vscode-arduino\vsix\*.vsix |
| 175 | + isPreRelease: $[contains(variables['Build.SourceBranch'], '-rc')] |
| 176 | + condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags')) |
| 177 | + |
| 178 | + - task: MicroBuildCleanup@1 |
| 179 | + displayName: Clean up MicroBuild |
0 commit comments