trigger:
  - main

name: 'ITD.Shared-ServiceNow'

variables:
  major: 0
  minor: 8
  patch: $(Build.BuildID)
  buildVer: $(major).$(minor).$(Build.BuildID)

pool: itdwinautop1

stages:
- stage: Build
  jobs:
  - job: Build
    steps:
    - task: PowerShell@2
      inputs:
        filePath: '$(System.DefaultWorkingDirectory)/Build/build.ps1'
    - task: NuGetCommand@2
      inputs:
        command: 'pack'
        packagesToPack: '$(System.DefaultWorkingDirectory)/ITD.Shared-ServiceNow.nuspec'
        versioningScheme: byEnvVar
        versionEnvVar: buildVer
        buildProperties: 'VERSIONHERE=$(buildVer)'
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'NuGetPackage'
        publishLocation: 'Container'
- stage: Deploy
  jobs:
  - job: Deploy
    steps:
      - task: DownloadPipelineArtifact@2
        inputs:
          buildType: 'current'
          artifactName: 'NuGetPackage'
          itemPattern: '**'
          targetPath: '$(Pipeline.Workspace)'
      - task: NuGetCommand@2
        inputs:
          command: 'push'
          packagesToPush: '$(Pipeline.Workspace)/ITD.Shared-ServiceNow.$(major).$(minor).$(Build.BuildID).nupkg'
          nuGetFeedType: external
          publishFeedCredentials: 'ITD_PwshGallery'