Skip to content

Commit f035f0b

Browse files
committed
Fix getting versions on Windows
1 parent af9e213 commit f035f0b

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

.github/workflows/test-windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ jobs:
5959
run: |
6060
# We need to get the version here and make it an environment variable
6161
# It is used to install via bootstrap and in the test
62-
# The version is in the instance name
62+
# The version is in the instance name:
63+
# ["stable-3006", "stable-3006-8", "stable-3007", "stable-3007-1", "latest"]
6364
$instance = "${{ matrix.instance }}"
6465
$version = $instance -split "-",2
6566
if ( $version.Count -gt 1 ) {

bootstrap-salt.ps1

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,36 @@ function Get-AvailableVersions {
207207
Write-Verbose "- $_"
208208
}
209209

210-
# Get the latest version, should be the last in the list
211-
Write-Verbose "Getting latest available version"
212-
$latest = $available_versions | Select-Object -Last 1
213-
Write-Verbose "Latest available version: $latest"
214-
215210
# Create a versions table
216211
# This will have the latest version available, the latest version available
217212
# for each major version, and every version available. This makes the
218213
# version lookup logic easier. The contents of the versions table can be
219214
# found by running -Verbose
220215
Write-Verbose "Populating the versions table"
221-
$versions_table = [ordered]@{"latest"=$latest}
216+
$versions_table = [ordered]@{}
222217
$available_versions | ForEach-Object {
223-
$versions_table[$(Get-MajorVersion $_)] = $_
218+
$major_version = $(Get-MajorVersion $_)
219+
if ( $versions_table.Keys -contains $major_version ) {
220+
if ( [System.Version]$_ -gt [System.Version]$versions_table[$major_version] ) {
221+
$versions_table[$major_version] = $_
222+
}
223+
} else {
224+
$versions_table[$major_version] = $_
225+
}
226+
227+
if ( $versions_table -contains "latest" ) {
228+
if ( [System.Version]$_ -gt [System.Version]$versions_table["latest"] ) {
229+
$versions_table["latest"] = $_
230+
}
231+
} else {
232+
$versions_table["latest"] = $_
233+
}
234+
224235
$versions_table[$_.ToLower()] = $_.ToLower()
225236
}
226237

227238
Write-Verbose "Versions Table:"
228-
$versions_table | Sort-Object Name | Out-String | ForEach-Object {
239+
$versions_table.GetEnumerator() | Sort-Object Name | Out-String | ForEach-Object {
229240
Write-Verbose "$_"
230241
}
231242

0 commit comments

Comments
 (0)