|
| 1 | +name: PlatyPS-Release-$(Build.BuildId) |
| 2 | +trigger: none |
| 3 | + |
| 4 | +pr: |
| 5 | + branches: |
| 6 | + include: |
| 7 | + - v2 |
| 8 | + - release/v2/* |
| 9 | + |
| 10 | +variables: |
| 11 | + - group: ESRP |
| 12 | + - name: DOTNET_CLI_TELEMETRY_OPTOUT |
| 13 | + value: 1 |
| 14 | + - name: POWERSHELL_TELEMETRY_OPTOUT |
| 15 | + value: 1 |
| 16 | + |
| 17 | +resources: |
| 18 | + repositories: |
| 19 | + - repository: ComplianceRepo |
| 20 | + type: github |
| 21 | + endpoint: ComplianceGHRepo |
| 22 | + name: PowerShell/compliance |
| 23 | + |
| 24 | +stages: |
| 25 | +- stage: Build |
| 26 | + displayName: Build |
| 27 | + pool: |
| 28 | + name: 1ES |
| 29 | + demands: |
| 30 | + - ImageOverride -equals MMS2019 |
| 31 | + jobs: |
| 32 | + - job: Build_Job |
| 33 | + displayName: Build PlatyPS |
| 34 | + steps: |
| 35 | + - checkout: self |
| 36 | + clean: true |
| 37 | + - pwsh: | |
| 38 | + $versionString = if ($env:RELEASE_VERSION -eq 'fromBranch') { |
| 39 | + $branch = $env:BUILD_SOURCEBRANCH |
| 40 | + $branchOnly = $branch -replace '^refs/heads/' |
| 41 | + $branchOnly -replace '^.*(release/v2[-/])' |
| 42 | + } |
| 43 | + else { |
| 44 | + $env:RELEASE_VERSION |
| 45 | + } |
| 46 | +
|
| 47 | + $nugetVersion = if ($versionString.StartsWith('v')) { |
| 48 | + $versionString.Substring(1) |
| 49 | + } |
| 50 | + else { |
| 51 | + $versionString |
| 52 | + } |
| 53 | +
|
| 54 | + $vstsCommandString = "vso[task.setvariable variable=Version]$nugetVersion" |
| 55 | + Write-Verbose -Message "setting Version to $releaseTag" -Verbose |
| 56 | + Write-Host -Object "##$vstsCommandString" |
| 57 | + displayName: Set NuGet package version variable |
| 58 | +
|
| 59 | + - pwsh: | |
| 60 | + ./build.ps1 -Clean -Configuration 'Release' |
| 61 | + displayName: Execute build |
| 62 | +
|
| 63 | + - publish: '$(Build.SourcesDirectory)\out\platyPS' |
| 64 | + artifact: build |
| 65 | + displayName: Publish build package |
| 66 | + |
| 67 | + - template: EsrpSign.yml@ComplianceRepo |
| 68 | + parameters: |
| 69 | + buildOutputPath: '$(Build.SourcesDirectory)\out\platyPS' |
| 70 | + signOutputPath: '$(Pipeline.Workspace)\signed\codesign' |
| 71 | + certificateId: 'CP-230012' |
| 72 | + displayName: Microsoft signing |
| 73 | + pattern: | |
| 74 | + **\Microsoft.PowerShell.PlatyPS.dll |
| 75 | + **\platyPS.psd1 |
| 76 | + useMinimatch: true |
| 77 | + |
| 78 | + - template: EsrpSign.yml@ComplianceRepo |
| 79 | + parameters: |
| 80 | + buildOutputPath: '$(Build.SourcesDirectory)\out\platyPS' |
| 81 | + signOutputPath: '$(Pipeline.Workspace)\signed\thirdparty' |
| 82 | + certificateId: 'CP-231522' |
| 83 | + displayName: Third party signing |
| 84 | + pattern: | |
| 85 | + **\Markdig.Signed.dll |
| 86 | + **\YamlDotNet.dll |
| 87 | + useMinimatch: true |
| 88 | + |
| 89 | + - pwsh: | |
| 90 | + Copy-Item -Path "$env:BUILD_SOURCESDIRECTORY\out\platyPS" -Destination "$env:PIPELINE_WORKSPACE\signed" -recurse -verbose -force |
| 91 | + displayName: Dummy copy to signed |
| 92 | + condition: eq(variables['SkipSigning'], 'True') |
| 93 | +
|
| 94 | + - pwsh: | |
| 95 | + $null = New-Item -ItemType Directory -Path '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Force |
| 96 | +
|
| 97 | + if ( Test-Path -Path '$(Pipeline.Workspace)\signed\codesign') |
| 98 | + { |
| 99 | + Copy-Item -Path '$(Pipeline.Workspace)\signed\codesign\Microsoft.PowerShell.PlatyPS.dll' -Destination '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose -Force |
| 100 | + Copy-Item -Path '$(Pipeline.Workspace)\signed\codesign\platyPS.psd1' -Destination '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose -Force |
| 101 | + Copy-Item -Path '$(Pipeline.Workspace)\signed\thirdparty\Markdig.Signed.dll' -Destination '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose -Force |
| 102 | + Copy-Item -Path '$(Pipeline.Workspace)\signed\thirdparty\YamlDotNet.dll' -Destination '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose -Force |
| 103 | + } |
| 104 | + else |
| 105 | + { |
| 106 | + Copy-Item -Path '$(Pipeline.Workspace)\signed\*' -Destination '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose -Force |
| 107 | + } |
| 108 | + displayName: Copy signed files to module folder |
| 109 | +
|
| 110 | + - publish: '$(Pipeline.Workspace)\signed' |
| 111 | + artifact: signed |
| 112 | + displayName: Publish signed package |
| 113 | + condition: ne(variables['SkipSigning'], 'True') |
| 114 | + |
| 115 | + - publish: '$(Build.SourcesDirectory)\src\obj\project.assets.json' |
| 116 | + artifact: AssetsJson |
| 117 | + displayName: Publish project.assets.json |
| 118 | + |
| 119 | + - pwsh: | |
| 120 | + $null = New-Item -ItemType Directory -Path '$(System.ArtifactsDirectory)/local' |
| 121 | + Register-PSRepository -Name local -SourceLocation '$(System.ArtifactsDirectory)/local' -Verbose -ErrorAction Ignore |
| 122 | + Publish-Module -Repository local -Path '$(System.ArtifactsDirectory)/signedpackage/platyPS' -Verbose |
| 123 | + displayName: Create nupkg for the module |
| 124 | +
|
| 125 | + - publish: '$(System.ArtifactsDirectory)\local\platyPS.$(Version).nupkg' |
| 126 | + artifact: nuget |
| 127 | + displayName: Publish module nuget |
| 128 | + |
| 129 | +- stage: compliance |
| 130 | + displayName: Compliance |
| 131 | + dependsOn: Build |
| 132 | + jobs: |
| 133 | + - job: Compliance_Job |
| 134 | + pool: |
| 135 | + name: 1ES |
| 136 | + demands: |
| 137 | + - ImageOverride -equals MMS2019 |
| 138 | + steps: |
| 139 | + - checkout: self |
| 140 | + - checkout: ComplianceRepo |
| 141 | + |
| 142 | + - task: DownloadPipelineArtifact@2 |
| 143 | + displayName: 'Download AssetsJson artifacts' |
| 144 | + inputs: |
| 145 | + artifact: AssetsJson |
| 146 | + path: '$(Pipeline.Workspace)/AssetsJson' |
| 147 | + |
| 148 | + - task: DownloadPipelineArtifact@2 |
| 149 | + displayName: 'Download build artifacts' |
| 150 | + inputs: |
| 151 | + artifact: build |
| 152 | + path: '$(Pipeline.Workspace)/build' |
| 153 | + |
| 154 | + - pwsh: | |
| 155 | + Get-ChildItem -Recurse '$(Pipeline.Workspace)' |
| 156 | + displayName: Capture downloaded artifacts |
| 157 | +
|
| 158 | + - template: assembly-module-compliance.yml@ComplianceRepo |
| 159 | + parameters: |
| 160 | + # binskim |
| 161 | + AnalyzeTarget: '$(Pipeline.Workspace)/build/*.dll' |
| 162 | + AnalyzeSymPath: 'SRV*' |
| 163 | + # component-governance |
| 164 | + sourceScanPath: '$(Pipeline.Workspace)/AssetsJson' |
| 165 | + # credscan |
| 166 | + suppressionsFile: '' |
| 167 | + # TermCheck |
| 168 | + optionsRulesDBPath: '' |
| 169 | + optionsFTPath: '' |
| 170 | + # tsa-upload |
| 171 | + codeBaseName: 'PlatyPS_202105' |
| 172 | + # selections |
| 173 | + APIScan: false # set to false when not using Windows APIs. |
| 174 | + |
| 175 | +- template: template/publish.yml |
| 176 | + parameters: |
| 177 | + stageName: NuGet |
| 178 | + environmentName: PlatyPSNuGetApproval |
| 179 | + feedCredential: NugetOrgPush |
0 commit comments