Skip to content

Commit

Permalink
Update set-test-pipeline-version.yml to handle one or more packages (#…
Browse files Browse the repository at this point in the history
…29851)

Co-authored-by: James Suplizio <[email protected]>
  • Loading branch information
azure-sdk and JimSuplizio authored Jul 8, 2022
1 parent 2ab2683 commit 7ebbd9a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
parameters:
PackageName: ''
PackageNames: ''
ServiceDirectory: ''
TestPipeline: false

steps:
- ${{ if eq(parameters.TestPipeline, 'true') }}:
- task: PowerShell@2
displayName: Prep template pipeline for release
condition: and(succeeded(), ne(variables['Skip.SetTestPipelineVersion'], 'true'))
condition: and(succeeded(), ne(variables['Skip.SetTestPipelineVersion'], 'true'))
inputs:
pwsh: true
workingDirectory: $(Build.SourcesDirectory)
filePath: $(Build.SourcesDirectory)/eng/common/scripts/SetTestPipelineVersion.ps1
arguments: '-BuildID $(Build.BuildId) -PackageName ${{ parameters.PackageName }} -ServiceDirectory ${{ parameters.ServiceDirectory }}'
arguments: >
-BuildID $(Build.BuildId)
-PackageNames '${{ coalesce(parameters.PackageName, parameters.PackageNames) }}'
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
pwsh: true
60 changes: 36 additions & 24 deletions eng/common/scripts/SetTestPipelineVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,55 @@

param (
[Parameter(mandatory = $true)]
$BuildID,
[string]$BuildID,
[Parameter(mandatory = $true)]
$PackageName,
[string]$PackageNames,
[Parameter(mandatory = $true)]
$ServiceDirectory
[string]$ServiceDirectory
)

. (Join-Path $PSScriptRoot common.ps1)

Write-Host "PackageName: $PackageName"
Write-Host "PackageNames: $PackageNames"
Write-Host "ServiceDirectory: $ServiceDirectory"
Write-Host "BuildID: $BuildID"

$newVersion = [AzureEngSemanticVersion]::new("1.0.0")
$latestTags = git tag -l "${PackageName}_*"
$packageNamesArray = @()

Write-Host "Get Latest Tag : git tag -l ${PackageName}_*"
$semVars = @()
if ([String]::IsNullOrWhiteSpace($PackageNames)) {
LogError "PackageNames cannot be empty."
exit 1
} else {
$packageNamesArray = $PackageNames.Split(',')
}

foreach ($packageName in $packageNamesArray) {
Write-Host "Processing $packageName"
$newVersion = [AzureEngSemanticVersion]::new("1.0.0")
$latestTags = git tag -l "${packageName}_*"

Write-Host "Get Latest Tag : git tag -l ${packageName}_*"
$semVars = @()

if ($latestTags -and ($latestTags.Length -gt 0))
{
foreach ($tags in $latestTags)
if ($latestTags -and ($latestTags.Length -gt 0))
{
$semVars += $tags.Replace("${PackageName}_", "")
foreach ($tags in $latestTags)
{
$semVars += $tags.Replace("${packageName}_", "")
}

$semVarsSorted = [AzureEngSemanticVersion]::SortVersionStrings($semVars)
Write-Host "Last Published Version $($semVarsSorted[0])"
$newVersion = [AzureEngSemanticVersion]::new($semVarsSorted[0])
}

$semVarsSorted = [AzureEngSemanticVersion]::SortVersionStrings($semVars)
Write-Host "Last Published Version $($semVarsSorted[0])"
$newVersion = [AzureEngSemanticVersion]::new($semVarsSorted[0])
}

$newVersion.PrereleaseLabel = $newVersion.DefaultPrereleaseLabel
$newVersion.PrereleaseNumber = $BuildID
$newVersion.IsPrerelease = $True
$newVersion.PrereleaseLabel = $newVersion.DefaultPrereleaseLabel
$newVersion.PrereleaseNumber = $BuildID
$newVersion.IsPrerelease = $True

Write-Host "Version to publish [ $($newVersion.ToString()) ]"
Write-Host "Version to publish [ $($newVersion.ToString()) ]"

SetPackageVersion -PackageName $PackageName `
-Version $newVersion.ToString() `
-ServiceDirectory $ServiceDirectory
SetPackageVersion -PackageName $packageName `
-Version $newVersion.ToString() `
-ServiceDirectory $ServiceDirectory
}

0 comments on commit 7ebbd9a

Please sign in to comment.