Skip to content

Commit

Permalink
Set version artificially for the test template runs
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Sep 30, 2020
1 parent 2e26618 commit cae50c1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
10 changes: 9 additions & 1 deletion eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/templates/stages/archetype-python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
8 changes: 8 additions & 0 deletions eng/pipelines/templates/steps/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
39 changes: 39 additions & 0 deletions eng/scripts/SetTestPipelineVersion.ps1
Original file line number Diff line number Diff line change
@@ -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
"@

0 comments on commit cae50c1

Please sign in to comment.