Skip to content

Commit

Permalink
improve version parser
Browse files Browse the repository at this point in the history
  • Loading branch information
max-ieremenko committed Apr 13, 2024
1 parent 3d4b0cc commit 79ccfc9
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions build/show-powershell-images.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#Requires -Version "7.0"

$ErrorActionPreference = "Stop"
$ErrorActionPreference = 'Stop'

function Get-ShortVersion {
[CmdletBinding()]
Expand All @@ -11,18 +9,27 @@ function Get-ShortVersion {
)

process {
$parts = $FullVersion -split "-"
$result = $parts[0]
# preview-7.5-ubuntu-20.04
# 7.4-ubuntu-22.04
# 7.3.0-preview.1-ubuntu-20.04
$parts = $FullVersion -split '-'
$version = $parts[0]
$tag = $parts[1]

if ($version -like 'preview*') {
$version = $parts[1]
$tag = $parts[0]
}

if ($parts[1] -like "preview*") {
$result += "-" + $parts[1]
if ($tag -like 'preview*') {
$version += '-' + $tag
}

return $result
return $version
}
}

(Invoke-RestMethod -Uri "https://mcr.microsoft.com/v2/powershell/tags/list").tags `
| Where-Object {$_ -Like "[0-9]*"} `
| Get-ShortVersion `
| Sort-Object -Unique
(Invoke-RestMethod -Uri 'https://mcr.microsoft.com/v2/powershell/tags/list').tags `
| Where-Object { ($_ -Like '[0-9]*') -or ($_ -Like 'preview-[0-9]*') } `
| Get-ShortVersion `
| Sort-Object -Unique

0 comments on commit 79ccfc9

Please sign in to comment.