mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
[Windows] Pin MongoDB to the specific version defined in the toolset (#4418)
This commit is contained in:
@@ -29,4 +29,36 @@ function Choco-Install {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Send-RequestToCocolateyPackages {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $FilterQuery,
|
||||
[string] $Url = "https://community.chocolatey.org/api",
|
||||
[int] $ApiVersion = 2
|
||||
)
|
||||
|
||||
$response = Invoke-RestMethod "$Url/v$ApiVersion/Packages()?$filterQuery"
|
||||
|
||||
return $response
|
||||
}
|
||||
|
||||
function Get-LatestChocoPackageVersion {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $PackageName,
|
||||
[Parameter(Mandatory)]
|
||||
[string] $TargetVersion
|
||||
)
|
||||
|
||||
$versionNumbers = $TargetVersion.Split(".")
|
||||
[int]$versionNumbers[-1] += 1
|
||||
$incrementedVersion = $versionNumbers -join "."
|
||||
$filterQuery = "`$filter=(Id eq '$PackageName') and (IsPrerelease eq false) and (Version ge '$TargetVersion') and (Version lt '$incrementedVersion')"
|
||||
$latestVersion = (Send-RequestToCocolateyPackages -FilterQuery $filterQuery).properties.Version |
|
||||
Sort-Object {[version]$_} |
|
||||
Select-Object -Last 1
|
||||
|
||||
return $latestVersion
|
||||
}
|
||||
Reference in New Issue
Block a user