|
| 1 | +################################################################################# |
| 2 | +# OneBranch Pipelines # |
| 3 | +# This pipeline was created by EasyStart from a sample located at: # |
| 4 | +# https://aka.ms/obpipelines/easystart/samples # |
| 5 | +# Documentation: https://aka.ms/obpipelines # |
| 6 | +# Yaml Schema: https://aka.ms/obpipelines/yaml/schema # |
| 7 | +# Retail Tasks: https://aka.ms/obpipelines/tasks # |
| 8 | +# Support: https://aka.ms/onebranchsup # |
| 9 | +################################################################################# |
| 10 | + |
| 11 | +trigger: none |
| 12 | + |
| 13 | +parameters: |
| 14 | +- name: debug |
| 15 | + displayName: Enable debug output |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + |
| 19 | +variables: |
| 20 | + system.debug: ${{ parameters.debug }} |
| 21 | + BuildConfiguration: Release |
| 22 | + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest |
| 23 | + DOTNET_NOLOGO: true |
| 24 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 25 | + DOTNET_GENERATE_ASPNET_CERTIFICATE: false |
| 26 | + |
| 27 | +resources: |
| 28 | + repositories: |
| 29 | + - repository: templates |
| 30 | + type: git |
| 31 | + name: OneBranch.Pipelines/GovernedTemplates |
| 32 | + ref: refs/heads/main |
| 33 | + |
| 34 | +extends: |
| 35 | + # https://aka.ms/obpipelines/templates |
| 36 | + template: v2/OneBranch.Official.CrossPlat.yml@templates |
| 37 | + parameters: |
| 38 | + globalSdl: # https://aka.ms/obpipelines/sdl |
| 39 | + asyncSdl: |
| 40 | + enabled: true |
| 41 | + stages: |
| 42 | + - stage: build |
| 43 | + jobs: |
| 44 | + - job: main |
| 45 | + displayName: Build package |
| 46 | + pool: |
| 47 | + type: windows |
| 48 | + variables: |
| 49 | + ob_outputDirectory: $(Build.SourcesDirectory)/module |
| 50 | + steps: |
| 51 | + - pwsh: | |
| 52 | + [xml]$xml = Get-Content PowerShellEditorServices.Common.props |
| 53 | + $version = $xml.Project.PropertyGroup.VersionPrefix |
| 54 | + Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" |
| 55 | + name: package |
| 56 | + displayName: Get version from project properties |
| 57 | + - task: onebranch.pipeline.version@1 |
| 58 | + displayName: Set OneBranch version |
| 59 | + inputs: |
| 60 | + system: Custom |
| 61 | + customVersion: $(package.version) |
| 62 | + - task: UseDotNet@2 |
| 63 | + displayName: Install .NET 8.x SDK |
| 64 | + inputs: |
| 65 | + packageType: sdk |
| 66 | + version: 8.x |
| 67 | + - task: UseDotNet@2 |
| 68 | + displayName: Install .NET 7.x runtime |
| 69 | + inputs: |
| 70 | + packageType: runtime |
| 71 | + version: 7.x |
| 72 | + - task: UseDotNet@2 |
| 73 | + displayName: Install .NET 6.x runtime |
| 74 | + inputs: |
| 75 | + packageType: runtime |
| 76 | + version: 6.x |
| 77 | + - task: PowerShell@2 |
| 78 | + displayName: Install PSResources |
| 79 | + inputs: |
| 80 | + pwsh: true |
| 81 | + filePath: tools/installPSResources.ps1 |
| 82 | + - task: PowerShell@2 |
| 83 | + displayName: Build and test |
| 84 | + inputs: |
| 85 | + targetType: inline |
| 86 | + pwsh: true |
| 87 | + script: Invoke-Build TestFull -Configuration $(BuildConfiguration) |
| 88 | + - task: PublishTestResults@2 |
| 89 | + displayName: Publish test results |
| 90 | + inputs: |
| 91 | + testRunner: VSTest |
| 92 | + testResultsFiles: '**/*.trx' |
| 93 | + failTaskOnFailedTests: true |
| 94 | + - task: PowerShell@2 |
| 95 | + displayName: Assert release configuration |
| 96 | + inputs: |
| 97 | + targetType: inline |
| 98 | + pwsh: true |
| 99 | + script: | |
| 100 | + $assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/module/PowerShellEditorServices/bin/Core/Microsoft.PowerShell.EditorServices.Hosting.dll") |
| 101 | + if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { |
| 102 | + Write-Host "##vso[task.LogIssue type=error;]Was not built in release configuration!" |
| 103 | + exit 1 |
| 104 | + } |
| 105 | + - task: onebranch.pipeline.signing@1 |
| 106 | + displayName: Sign 1st-party files |
| 107 | + inputs: |
| 108 | + command: sign |
| 109 | + signing_environment: external_distribution |
| 110 | + search_root: $(Build.SourcesDirectory)/module |
| 111 | + files_to_sign: | |
| 112 | + **/*.ps1; |
| 113 | + **/*.psd1; |
| 114 | + **/*.psm1; |
| 115 | + **/*.ps1xml; |
| 116 | + **/Microsoft.PowerShell.EditorServices*.dll; |
| 117 | + !Plaster/*; |
| 118 | + - task: onebranch.pipeline.signing@1 |
| 119 | + displayName: Sign 3rd-party files |
| 120 | + inputs: |
| 121 | + command: sign |
| 122 | + signing_environment: 135020002 |
| 123 | + search_root: $(Build.SourcesDirectory)/module |
| 124 | + files_to_sign: | |
| 125 | + **/MediatR.dll; |
| 126 | + **/Nerdbank.Streams.dll; |
| 127 | + **/Newtonsoft.Json.dll; |
| 128 | + **/OmniSharp.Extensions*.dll; |
| 129 | + **/Serilog*.dll; |
| 130 | + **/System.Reactive.dll; |
| 131 | + Plaster/**/*.ps1; |
| 132 | + Plaster/**/*.psd1; |
| 133 | + Plaster/**/*.psm1; |
| 134 | + - stage: release |
| 135 | + dependsOn: build |
| 136 | + variables: |
| 137 | + version: $[ stageDependencies.build.main.outputs['package.version'] ] |
| 138 | + drop: $(Pipeline.Workspace)/drop_build_main |
| 139 | + jobs: |
| 140 | + - job: validation |
| 141 | + displayName: Manual validation |
| 142 | + pool: |
| 143 | + type: agentless |
| 144 | + timeoutInMinutes: 1440 |
| 145 | + steps: |
| 146 | + - task: ManualValidation@0 |
| 147 | + displayName: Wait 24 hours for validation |
| 148 | + inputs: |
| 149 | + notifyUsers: $(Build.RequestedForEmail) |
| 150 | + instructions: Please validate the release |
| 151 | + timeoutInMinutes: 1440 |
| 152 | + - job: github |
| 153 | + dependsOn: validation |
| 154 | + displayName: Publish draft to GitHub |
| 155 | + pool: |
| 156 | + type: windows |
| 157 | + variables: |
| 158 | + ob_outputDirectory: $(Build.SourcesDirectory)/out |
| 159 | + steps: |
| 160 | + - download: current |
| 161 | + displayName: Download artifacts |
| 162 | + - task: ArchiveFiles@2 |
| 163 | + displayName: Zip signed artifacts |
| 164 | + inputs: |
| 165 | + rootFolderOrFile: $(drop) |
| 166 | + includeRootFolder: false |
| 167 | + archiveType: zip |
| 168 | + archiveFile: out/PowerShellEditorServices.zip |
| 169 | + - task: GitHubRelease@1 |
| 170 | + displayName: Create GitHub release |
| 171 | + inputs: |
| 172 | + gitHubConnection: GitHub |
| 173 | + repositoryName: PowerShell/PowerShellEditorServices |
| 174 | + action: create |
| 175 | + assets: out/PowerShellEditorServices.zip |
| 176 | + releaseNotesFilePath: CHANGELOG.md |
| 177 | + tagSource: userSpecifiedTag |
| 178 | + tag: v$(version) |
| 179 | + isDraft: true |
0 commit comments