-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCheckForNugetPublish.ps1
More file actions
42 lines (35 loc) · 1.13 KB
/
CheckForNugetPublish.ps1
File metadata and controls
42 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
param (
[Parameter(Mandatory = $true)]
[string]$packageName,
[Parameter(Mandatory = $true)]
[string]$expectedVersion
)
function Get-LatestPackageVersion {
param (
[string]$packageName
)
$nugetUrl = "https://api.nuget.org/v3-flatcontainer/$packageName/index.json"
try {
$response = Invoke-RestMethod -Uri $nugetUrl
$latestVersion = $response.versions[-1] # Get the last version as it's the latest
return $latestVersion
}
catch {
Write-Host "An error occurred while fetching the package version: $_"
return $null
}
}
while ($true) {
$latestVersion = Get-LatestPackageVersion -packageName $packageName
if ($latestVersion -eq $null) {
Write-Host "Failed to retrieve the package version. Retrying in 5 seconds..."
}
elseif ($latestVersion -eq $expectedVersion) {
Write-Host "The latest version ($latestVersion) matches the expected version ($expectedVersion)."
break
}
else {
Write-Host "The latest version is $latestVersion. Waiting for version $expectedVersion..."
}
Start-Sleep -Seconds 5
}