Skip to content

Commit

Permalink
Update Get-AWSCLI.ps1
Browse files Browse the repository at this point in the history
Update to use Get-GitHubRepoTag #544
  • Loading branch information
aaronparker committed Sep 25, 2024
1 parent 507d118 commit 5f35791
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Evergreen/Apps/Get-AWSCLI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,17 @@ function Get-AWSCLI {
$res = (Get-FunctionResource -AppName ("$($MyInvocation.MyCommand)".Split("-"))[1])
)

# Get latest version and download latest release via GitHub API
$params = @{
Uri = $res.Get.Update.Uri
ContentType = $res.Get.Update.ContentType
ReturnObject = "Content"
}
# Get the latest version of AWS CLI via the latest tag on the repository
$Tags = Get-GitHubRepoTag -Uri $res.Get.Update.Uri

# Get only latest version tag from GitHub API
$Content = ((Invoke-EvergreenWebRequest @params | ConvertFrom-Json).name | ForEach-Object { New-Object -TypeName "System.Version" ($_) } | Sort-Object -Descending | Select-Object -First 1 | ForEach-Object {("{0}.{1}.{2}" -f $_.Major,$_.Minor,$_.Build)})
# Select the latest version
$Version = $Tags | Sort-Object -Property @{ Expression = { [System.Version]$_.Tag }; Descending = $true } | Select-Object -First 1

if ($null -ne $Content) {
$Content | ForEach-Object {
$PSObject = [PSCustomObject] @{
Version = $_
Type = "msi"
URI = $res.Get.Download.Uri -replace $res.Get.Download.ReplaceText, $_
}
Write-Output -InputObject $PSObject
}
# Output the version and download URL
$PSObject = [PSCustomObject] @{
Version = $Version.Tag
Type = "msi"
URI = $res.Get.Download.Uri -replace $res.Get.Download.ReplaceText, $Version.Tag
}
Write-Output -InputObject $PSObject
}

0 comments on commit 5f35791

Please sign in to comment.