parameters:
- name: PublishingNuget
  displayName: Publishing Nuget Packages
  type: boolean
  default: true
stages:
- stage: Publish_NuGet_Package_And_Report
  condition: and (succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
  jobs:
  - job:
    workspace:
      clean: all
    variables:
    - name: GDN_CODESIGN_TARGETDIRECTORY
      value: '$(Build.BinariesDirectory)/nuget-artifact/final-package'
    pool: 'onnxruntime-Win-CPU-2022'

    steps:
    - checkout: self
      submodules: false
    - template: set-version-number-variables-step.yml

    - task: DownloadPipelineArtifact@0
      displayName: 'Download Pipeline Artifact - Signed NuGet Package'
      inputs:
        artifactName: 'drop-signed-nuget-CPU'
        targetPath: $(Build.BinariesDirectory)/nuget-artifact/final-package

    - template: component-governance-component-detection-steps.yml
      parameters :
        condition : 'succeeded'
    - task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
      displayName: 'Clean Agent Directories'
      condition: always()
