|
| 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: |
| 12 | + - main |
| 13 | + |
| 14 | +schedules: |
| 15 | + - cron: "35 13 * * 4" |
| 16 | + displayName: Weekly CodeQL |
| 17 | + branches: |
| 18 | + include: |
| 19 | + - main |
| 20 | + always: true |
| 21 | + |
| 22 | +resources: |
| 23 | + repositories: |
| 24 | + - repository: templates |
| 25 | + type: git |
| 26 | + name: OneBranch.Pipelines/GovernedTemplates |
| 27 | + ref: refs/heads/main |
| 28 | + |
| 29 | +parameters: |
| 30 | + - name: debug |
| 31 | + displayName: Enable debug output |
| 32 | + type: boolean |
| 33 | + default: false |
| 34 | + - name: OfficialBuild |
| 35 | + displayName: Use Official OneBranch template |
| 36 | + type: boolean |
| 37 | + default: true |
| 38 | + - name: Release |
| 39 | + displayName: Generate a release |
| 40 | + type: boolean |
| 41 | + default: false |
| 42 | + |
| 43 | +variables: |
| 44 | + system.debug: ${{ parameters.debug }} |
| 45 | + BuildConfiguration: Release |
| 46 | + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest |
| 47 | + DOTNET_NOLOGO: true |
| 48 | + DOTNET_GENERATE_ASPNET_CERTIFICATE: false |
| 49 | + OneBranchTemplate: ${{ iif(parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@templates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@templates') }} |
| 50 | + |
| 51 | +extends: |
| 52 | + # https://aka.ms/obpipelines/templates |
| 53 | + template: ${{ variables.OneBranchTemplate }} |
| 54 | + parameters: |
| 55 | + globalSdl: # https://aka.ms/obpipelines/sdl |
| 56 | + asyncSdl: |
| 57 | + enabled: true |
| 58 | + forStages: [build] |
| 59 | + featureFlags: |
| 60 | + EnableCDPxPAT: false |
| 61 | + WindowsHostVersion: |
| 62 | + Version: 2022 |
| 63 | + Network: KS3 |
| 64 | + release: |
| 65 | + category: NonAzure |
| 66 | + stages: |
| 67 | + - stage: build |
| 68 | + jobs: |
| 69 | + - job: main |
| 70 | + displayName: Build package |
| 71 | + pool: |
| 72 | + type: windows |
| 73 | + variables: |
| 74 | + ob_outputDirectory: $(Build.SourcesDirectory)/out |
| 75 | + steps: |
| 76 | + - pwsh: | |
| 77 | + [xml]$xml = Get-Content PowerShellEditorServices.Common.props |
| 78 | + $version = $xml.Project.PropertyGroup.VersionPrefix |
| 79 | + $prerelease = $xml.Project.PropertyGroup.VersionSuffix |
| 80 | + if ($prerelease) { $version += "-$prerelease" } |
| 81 | + Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" |
| 82 | + Write-Output "##vso[task.setvariable variable=prerelease;isOutput=true]$(-not [string]::IsNullOrEmpty($prerelease))" |
| 83 | + name: package |
| 84 | + displayName: Get version from project properties |
| 85 | + - task: onebranch.pipeline.version@1 |
| 86 | + displayName: Set OneBranch version |
| 87 | + inputs: |
| 88 | + system: Custom |
| 89 | + customVersion: $(package.version) |
| 90 | + - task: UseDotNet@2 |
| 91 | + displayName: Use .NET 8.x SDK |
| 92 | + inputs: |
| 93 | + packageType: sdk |
| 94 | + useGlobalJson: true |
| 95 | + - pwsh: ./tools/installPSResources.ps1 -PSRepository CFS |
| 96 | + displayName: Install PSResources |
| 97 | + - pwsh: Invoke-Build TestFull -Configuration $(BuildConfiguration) -PSRepository CFS |
| 98 | + displayName: Build and test |
| 99 | + - task: PublishTestResults@2 |
| 100 | + displayName: Publish test results |
| 101 | + inputs: |
| 102 | + testRunner: VSTest |
| 103 | + testResultsFiles: "**/*.trx" |
| 104 | + failTaskOnFailedTests: true |
| 105 | + - pwsh: | |
| 106 | + $assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/module/PowerShellEditorServices/bin/Core/Microsoft.PowerShell.EditorServices.Hosting.dll") |
| 107 | + if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { |
| 108 | + Write-Host "##vso[task.LogIssue type=error;]Was not built in release configuration!" |
| 109 | + exit 1 |
| 110 | + } |
| 111 | + displayName: Assert release configuration |
| 112 | + continueOnError: true |
| 113 | + - task: onebranch.pipeline.signing@1 |
| 114 | + displayName: Sign 1st-party files |
| 115 | + inputs: |
| 116 | + command: sign |
| 117 | + signing_profile: external_distribution |
| 118 | + search_root: $(Build.SourcesDirectory)/module |
| 119 | + files_to_sign: | |
| 120 | + **/*.ps1; |
| 121 | + **/*.psd1; |
| 122 | + **/*.psm1; |
| 123 | + **/*.ps1xml; |
| 124 | + **/Microsoft.PowerShell.EditorServices*.dll; |
| 125 | + - task: onebranch.pipeline.signing@1 |
| 126 | + displayName: Sign 3rd-party files |
| 127 | + inputs: |
| 128 | + command: sign |
| 129 | + signing_profile: 135020002 |
| 130 | + search_root: $(Build.SourcesDirectory)/module |
| 131 | + files_to_sign: | |
| 132 | + **/MediatR.dll; |
| 133 | + **/Nerdbank.Streams.dll; |
| 134 | + **/Newtonsoft.Json.dll; |
| 135 | + **/OmniSharp.Extensions*.dll; |
| 136 | + **/System.Reactive.dll; |
| 137 | + - task: ArchiveFiles@2 |
| 138 | + displayName: Zip signed artifacts |
| 139 | + inputs: |
| 140 | + rootFolderOrFile: $(Build.SourcesDirectory)/module |
| 141 | + includeRootFolder: false |
| 142 | + archiveType: zip |
| 143 | + archiveFile: out/PowerShellEditorServices.zip |
| 144 | + - stage: release |
| 145 | + dependsOn: build |
| 146 | + condition: and(succeeded(), ${{ eq(parameters.Release, true) }}) |
| 147 | + variables: |
| 148 | + ob_release_environment: ${{ iif(parameters.OfficialBuild, 'Production', 'Test') }} |
| 149 | + version: $[ stageDependencies.build.main.outputs['package.version'] ] |
| 150 | + prerelease: $[ stageDependencies.build.main.outputs['package.prerelease'] ] |
| 151 | + jobs: |
| 152 | + - job: github |
| 153 | + displayName: Publish draft to GitHub |
| 154 | + pool: |
| 155 | + type: release |
| 156 | + templateContext: |
| 157 | + inputs: |
| 158 | + - input: pipelineArtifact |
| 159 | + artifactName: drop_build_main |
| 160 | + steps: |
| 161 | + - task: GitHubRelease@1 |
| 162 | + displayName: Create GitHub release |
| 163 | + inputs: |
| 164 | + gitHubConnection: github.com_andyleejordan |
| 165 | + repositoryName: PowerShell/PowerShellEditorServices |
| 166 | + target: main |
| 167 | + assets: $(Pipeline.Workspace)/PowerShellEditorServices.zip |
| 168 | + tagSource: userSpecifiedTag |
| 169 | + tag: v$(version) |
| 170 | + isDraft: true |
| 171 | + isPreRelease: $(prerelease) |
| 172 | + addChangeLog: false |
| 173 | + releaseNotesSource: inline |
| 174 | + releaseNotesInline: "<!-- TODO: Generate release notes on GitHub! -->" |
0 commit comments