post-build.yml 10.7 KB
Newer Older
1
parameters:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  # Which publishing infra should be used. THIS SHOULD MATCH THE VERSION ON THE BUILD MANIFEST.
  # Publishing V1 is no longer supported
  # Publishing V2 is no longer supported
  # Publishing V3 is the default
  - name: publishingInfraVersion
    displayName: Which version of publishing should be used to promote the build definition?
    type: number
    default: 3
    values:
    - 3

  - name: BARBuildId
    displayName: BAR Build Id
    type: number
    default: 0

  - name: PromoteToChannelIds
    displayName: Channel to promote BARBuildId to
    type: string
    default: ''

  - name: enableSourceLinkValidation
    displayName: Enable SourceLink validation
    type: boolean
    default: false

  - name: enableSigningValidation
    displayName: Enable signing validation
    type: boolean
    default: true

  - name: enableSymbolValidation
    displayName: Enable symbol validation
    type: boolean
    default: false

  - name: enableNugetValidation
    displayName: Enable NuGet validation
    type: boolean
    default: true
    
  - name: publishInstallersAndChecksums
    displayName: Publish installers and checksums
    type: boolean
    default: true

  - name: SDLValidationParameters
    type: object
    default:
      enable: false
52
      publishGdn: false
53 54 55 56
      continueOnError: false
      params: ''
      artifactNames: ''
      downloadArtifacts: true
57

58 59
  # These parameters let the user customize the call to sdk-task.ps1 for publishing
  # symbols & general artifacts as well as for signing validation
60 61 62 63 64 65 66 67 68 69 70 71 72 73
  - name: symbolPublishingAdditionalParameters
    displayName: Symbol publishing additional parameters
    type: string
    default: ''

  - name: artifactsPublishingAdditionalParameters
    displayName: Artifact publishing additional parameters
    type: string
    default: ''

  - name: signingValidationAdditionalParameters
    displayName: Signing validation additional parameters
    type: string
    default: ''
74

75
  # Which stages should finish execution before post-build stages start
76 77 78 79
  - name: validateDependsOn
    type: object
    default:
    - build
80

81 82 83 84
  - name: publishDependsOn
    type: object
    default:
    - Validate
85

86 87 88 89 90
  # Optional: Call asset publishing rather than running in a separate stage
  - name: publishAssetsImmediately
    type: boolean
    default: false

91
stages:
92
- ${{ if or(eq( parameters.enableNugetValidation, 'true'), eq(parameters.enableSigningValidation, 'true'), eq(parameters.enableSourceLinkValidation, 'true'), eq(parameters.SDLValidationParameters.enable, 'true')) }}:
93 94 95 96 97 98
  - stage: Validate
    dependsOn: ${{ parameters.validateDependsOn }}
    displayName: Validate Build Assets
    variables:
      - template: common-variables.yml
    jobs:
99
    - job:
100 101
      displayName: NuGet Validation
      condition: eq( ${{ parameters.enableNugetValidation }}, 'true')
102
      pool:
103 104 105 106 107
        # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
        ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
          name: VSEngSS-MicroBuild2022-1ES
          demands: Cmd
        # If it's not devdiv, it's dnceng
108
        ${{ else }}:
109 110 111
          name: NetCore1ESPool-Internal
          demands: ImageOverride -equals Build.Server.Amd64.VS2019

112
      steps:
113 114 115 116 117
        - template: setup-maestro-vars.yml
          parameters:
            BARBuildId: ${{ parameters.BARBuildId }}
            PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}

118 119
        - task: DownloadBuildArtifacts@0
          displayName: Download Package Artifacts
120
          inputs:
121 122 123 124 125 126
            buildType: specific
            buildVersionToDownload: specific
            project: $(AzDOProjectName)
            pipeline: $(AzDOPipelineId)
            buildId: $(AzDOBuildId)
            artifactName: PackageArtifacts
127
            checkDownloadedFiles: true
128

129 130 131 132 133 134
        - task: PowerShell@2
          displayName: Validate
          inputs:
            filePath: $(Build.SourcesDirectory)/eng/common/post-build/nuget-validation.ps1
            arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ 
              -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ 
135

136 137
    - job:
      displayName: Signing Validation
138
      condition: and( eq( ${{ parameters.enableSigningValidation }}, 'true'), ne( variables['PostBuildSign'], 'true'))
139
      pool:
140 141 142 143 144
        # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
        ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
          name: VSEngSS-MicroBuild2022-1ES
          demands: Cmd
        # If it's not devdiv, it's dnceng
145
        ${{ else }}:
146 147
          name: NetCore1ESPool-Internal
          demands: ImageOverride -equals Build.Server.Amd64.VS2019
148
      steps:
149 150 151 152 153
        - template: setup-maestro-vars.yml
          parameters:
            BARBuildId: ${{ parameters.BARBuildId }}
            PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}

154
        - task: DownloadBuildArtifacts@0
155
          displayName: Download Package Artifacts
156 157 158 159 160 161
          inputs:
            buildType: specific
            buildVersionToDownload: specific
            project: $(AzDOProjectName)
            pipeline: $(AzDOPipelineId)
            buildId: $(AzDOBuildId)
162
            artifactName: PackageArtifacts
163
            checkDownloadedFiles: true
164 165 166
            itemPattern: |
              **
              !**/Microsoft.SourceBuild.Intermediate.*.nupkg
167

168 169 170 171 172
        # This is necessary whenever we want to publish/restore to an AzDO private feed
        # Since sdk-task.ps1 tries to restore packages we need to do this authentication here
        # otherwise it'll complain about accessing a private feed.
        - task: NuGetAuthenticate@0
          displayName: 'Authenticate to AzDO Feeds'
173

174 175 176 177 178
        - task: PowerShell@2
          displayName: Enable cross-org publishing
          inputs:
            filePath: eng\common\enable-cross-org-publishing.ps1
            arguments: -token $(dn-bot-dnceng-artifact-feeds-rw)
179

180 181 182 183 184 185 186 187 188 189
        # Signing validation will optionally work with the buildmanifest file which is downloaded from
        # Azure DevOps above.
        - task: PowerShell@2
          displayName: Validate
          inputs:
            filePath: eng\common\sdk-task.ps1
            arguments: -task SigningValidation -restore -msbuildEngine vs
              /p:PackageBasePath='$(Build.ArtifactStagingDirectory)/PackageArtifacts'
              /p:SignCheckExclusionsFile='$(Build.SourcesDirectory)/eng/SignCheckExclusionsFile.txt'
              ${{ parameters.signingValidationAdditionalParameters }}
190

191 192 193 194
        - template: ../steps/publish-logs.yml
          parameters:
            StageLabel: 'Validation'
            JobLabel: 'Signing'
195

196 197 198 199
    - job:
      displayName: SourceLink Validation
      condition: eq( ${{ parameters.enableSourceLinkValidation }}, 'true')
      pool:
200 201 202 203 204
        # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
        ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
          name: VSEngSS-MicroBuild2022-1ES
          demands: Cmd
        # If it's not devdiv, it's dnceng
205
        ${{ else }}:
206 207
          name: NetCore1ESPool-Internal
          demands: ImageOverride -equals Build.Server.Amd64.VS2019
208
      steps:
209 210 211 212 213
        - template: setup-maestro-vars.yml
          parameters:
            BARBuildId: ${{ parameters.BARBuildId }}
            PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}

214 215 216 217 218 219 220 221 222
        - task: DownloadBuildArtifacts@0
          displayName: Download Blob Artifacts
          inputs:
            buildType: specific
            buildVersionToDownload: specific
            project: $(AzDOProjectName)
            pipeline: $(AzDOPipelineId)
            buildId: $(AzDOBuildId)
            artifactName: BlobArtifacts
223
            checkDownloadedFiles: true
224

225 226 227 228 229 230 231 232 233 234
        - task: PowerShell@2
          displayName: Validate
          inputs:
            filePath: $(Build.SourcesDirectory)/eng/common/post-build/sourcelink-validation.ps1
            arguments: -InputPath $(Build.ArtifactStagingDirectory)/BlobArtifacts/ 
              -ExtractPath $(Agent.BuildDirectory)/Extract/ 
              -GHRepoName $(Build.Repository.Name) 
              -GHCommit $(Build.SourceVersion)
              -SourcelinkCliVersion $(SourceLinkCLIVersion)
          continueOnError: true
235

236 237 238
    - template: /eng/common/templates/job/execute-sdl.yml
      parameters:
        enable: ${{ parameters.SDLValidationParameters.enable }}
239
        publishGuardianDirectoryToPipeline: ${{ parameters.SDLValidationParameters.publishGdn }}
240 241 242 243
        additionalParameters: ${{ parameters.SDLValidationParameters.params }}
        continueOnError: ${{ parameters.SDLValidationParameters.continueOnError }}
        artifactNames: ${{ parameters.SDLValidationParameters.artifactNames }}
        downloadArtifacts: ${{ parameters.SDLValidationParameters.downloadArtifacts }}
244

245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
- ${{ if ne(parameters.publishAssetsImmediately, 'true') }}:
  - stage: publish_using_darc
    ${{ if or(eq(parameters.enableNugetValidation, 'true'), eq(parameters.enableSigningValidation, 'true'), eq(parameters.enableSourceLinkValidation, 'true'), eq(parameters.SDLValidationParameters.enable, 'true')) }}:
      dependsOn: ${{ parameters.publishDependsOn }}
    ${{ else }}:
      dependsOn: ${{ parameters.validateDependsOn }}
    displayName: Publish using Darc
    variables:
      - template: common-variables.yml
    jobs:
    - job:
      displayName: Publish Using Darc
      timeoutInMinutes: 120
      pool:
        # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
260 261 262 263
        ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
          name: VSEngSS-MicroBuild2022-1ES
          demands: Cmd
        # If it's not devdiv, it's dnceng
264
        ${{ else }}:
265 266
          name: NetCore1ESPool-Internal
          demands: ImageOverride -equals Build.Server.Amd64.VS2019
267 268 269 270 271
      steps:
        - template: setup-maestro-vars.yml
          parameters:
            BARBuildId: ${{ parameters.BARBuildId }}
            PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}
272

273
        - task: NuGetAuthenticate@0
274

275 276 277 278 279 280 281 282 283 284 285
        - task: PowerShell@2
          displayName: Publish Using Darc
          inputs:
            filePath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1
            arguments: -BuildId $(BARBuildId) 
              -PublishingInfraVersion ${{ parameters.publishingInfraVersion }}
              -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)'
              -MaestroToken '$(MaestroApiAccessToken)'
              -WaitPublishingFinish true
              -ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
              -SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'