name: $(SourceBranchName)-$(Date:yyyyMMdd).$(rev:r)

trigger:
  branches:
    include:
    - release/*

pr: none

variables:
- group: open-api-extension-variable-group
- name: TestRunStatus
  value: ''
- name: Version
  value: ''

stages:
- stage: BuildPublish
  displayName: 'Release: Build and Publish'

  jobs:
  - job: BuildTestPublish
    displayName: 'Release: Build, Test and Publish on Windows'

    pool:
      vmImage: 'windows-latest'

    workspace:
      clean: all

    steps:
    - task: PowerShell@2
      displayName: 'Get Branch Name'
      inputs:
        targetType: Inline
        script: |
          Write-Host "Branch: $(Build.SourceBranch)"
          Write-Host "BranchName: $(Build.SourceBranchName)"

          $version = "$(Build.SourceBranchName)".TrimStart("v")
          Write-Host "Version: $version"
          Write-Host "##vso[task.setvariable variable=Version]$version"

    - template: 'template-steps-build-test.yaml'
      parameters:
        configuration: 'Release'
    - template: 'template-steps-publish.yaml'
      parameters:
        configuration: 'Release'
        version: '$(Version)'

# - stage: Release
#   displayName: 'Release: To NuGet'

#   jobs:
#   - template: 'template-job-release.yaml'
