From cae50c1ab95666ed569a9123ed5e60a8b96f50d6 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 30 Sep 2020 13:28:32 -0700 Subject: [PATCH] Set version artificially for the test template runs --- .../templates/jobs/archetype-sdk-client.yml | 10 ++++- .../stages/archetype-python-release.yml | 7 ++++ .../templates/steps/build-artifacts.yml | 8 ++++ eng/scripts/SetTestPipelineVersion.ps1 | 39 +++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) 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 aaefeb2122432..efb4260935284 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -111,7 +111,15 @@ jobs: pool: vmImage: '$(OSVmImage)' - steps: + 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: | $toxenvvar = "whl,sdist" if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) { diff --git a/eng/pipelines/templates/stages/archetype-python-release.yml b/eng/pipelines/templates/stages/archetype-python-release.yml index 0a52aa70fc417..b525a91413bc1 100644 --- a/eng/pipelines/templates/stages/archetype-python-release.yml +++ b/eng/pipelines/templates/stages/archetype-python-release.yml @@ -28,6 +28,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/pipelines/templates/steps/stage-filtered-artifacts.yml parameters: SourceFolder: ${{parameters.ArtifactName}} diff --git a/eng/pipelines/templates/steps/build-artifacts.yml b/eng/pipelines/templates/steps/build-artifacts.yml index 8550d1567db7e..d6e72ed32f026 100644 --- a/eng/pipelines/templates/steps/build-artifacts.yml +++ b/eng/pipelines/templates/steps/build-artifacts.yml @@ -5,6 +5,14 @@ parameters: BuildDocs: true 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 + - script: | echo "##vso[build.addbuildtag]Scheduled" displayName: 'Tag scheduled builds' diff --git a/eng/scripts/SetTestPipelineVersion.ps1 b/eng/scripts/SetTestPipelineVersion.ps1 new file mode 100644 index 0000000000000..65c095a0bffdb --- /dev/null +++ b/eng/scripts/SetTestPipelineVersion.ps1 @@ -0,0 +1,39 @@ +# 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 = @() + +$versionFile = "${PSScriptRoot}\..\..\sdk\template\azure-template\azure\template\_version.py" +$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()) ]" + +$versionFileContent = Get-Content -Path $versionFile +$newVersionFile = @() + +Foreach ($line in $versionFileContent) +{ + if($line.StartsWith("VERSION")) + { + $line = 'VERSION = "{0}"' -F $newVersion.ToString() + } + $newVersionFile += $line +} + +Set-Content -Path $versionFile -Value $newVersionFile +Set-Content -Path $changeLogFile -Value @" +# Release History +## $($newVersion.ToString()) ($(Get-Date -f "yyyy-MM-dd")) +- Test Release Pipeline +"@