From cf77875e80ab2e8f13ed78ac9be7d5baaf4ec803 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com> Date: Thu, 1 Oct 2020 13:41:10 -0700 Subject: [PATCH] Set version artificially for the test template runs (#15550) --- .../templates/jobs/archetype-sdk-client.yml | 7 +++++ .../stages/archetype-net-release.yml | 7 +++++ eng/scripts/SetTestPipelineVersion.ps1 | 28 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 eng/scripts/SetTestPipelineVersion.ps1 diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 5474e5ffa4792..69aa4cb88698c 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -5,6 +5,13 @@ jobs: pool: vmImage: windows-2019 steps: + - task: PowerShell@2 + displayName: Prep template pipeline for release + condition: and(succeeded(),eq(variables['TestPipeline'],'true')) + inputs: + pwsh: true + workingDirectory: $(Build.SourcesDirectory) + filePath: eng/scripts/SetTestPipelineVersion.ps1 - pwsh: | echo "##vso[build.addbuildtag]Scheduled" displayName: "Tag scheduled builds" diff --git a/eng/pipelines/templates/stages/archetype-net-release.yml b/eng/pipelines/templates/stages/archetype-net-release.yml index 2babd97f39c31..c43ec18691082 100644 --- a/eng/pipelines/templates/stages/archetype-net-release.yml +++ b/eng/pipelines/templates/stages/archetype-net-release.yml @@ -54,6 +54,13 @@ stages: deploy: steps: - checkout: self + - task: PowerShell@2 + displayName: Prep template pipeline for release + condition: and(succeeded(),eq(variables['TestPipeline'],'true')) + inputs: + pwsh: true + workingDirectory: $(Build.SourcesDirectory) + filePath: eng/scripts/SetTestPipelineVersion.ps1 - template: /eng/common/pipelines/templates/steps/verify-changelog.yml parameters: PackageName: ${{artifact.name}} diff --git a/eng/scripts/SetTestPipelineVersion.ps1 b/eng/scripts/SetTestPipelineVersion.ps1 new file mode 100644 index 0000000000000..5fa37506dca24 --- /dev/null +++ b/eng/scripts/SetTestPipelineVersion.ps1 @@ -0,0 +1,28 @@ +# Overides the project file and CHANGELOG.md for the template project using the next publishable version +# This is to help with testing the release pipeline. +. "${PSScriptRoot}\..\common\scripts\common.ps1" +$latestTags = git tag -l "Azure.Template_*" +$semVars = @() + +$changeLogFile = "${PSScriptRoot}\..\..\sdk\template\Azure.Template\CHANGELOG.md" + +Foreach ($tags in $latestTags) +{ + $semVars += $tags.Replace("Azure.Template_", "") +} + +$semVarsSorted = [AzureEngSemanticVersion]::SortVersionStrings($semVars) +LogDebug "Last Published Version $($semVarsSorted[0])" + +$newVersion = [AzureEngSemanticVersion]::ParseVersionString($semVarsSorted[0]) +$newVersion.IncrementAndSetToPrerelease() +LogDebug "Version to publish [ $($newVersion.ToString()) ]" + +&"${PSScriptRoot}/Update-PkgVersion.ps1" -ServiceDirectory "template" ` +-PackageName 'Azure.Template' -PackageDirName "Azure.Template" -NewVersionString $newVersion.ToString() ` +-ReleaseDate (Get-Date -f "yyyy-MM-dd") +Set-Content -Path $changeLogFile -Value @" +# Release History +## $($newVersion.ToString()) ($(Get-Date -f "yyyy-MM-dd")) +- Test Release Pipeline +"@