Merge pull request #488 from Romanitho/new-upgrade

API Rate limite workarround
pull/490/head
Romain 2023-11-17 15:12:09 +01:00 committed by GitHub
commit c1d80d09f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 6 deletions

View File

@ -8,18 +8,34 @@ function Get-WAUAvailableVersion {
#Log #Log
Write-ToLog "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" Write-ToLog "WAU AutoUpdate Pre-release versions is Enabled" "Cyan"
#Get latest pre-release info try {
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases' #Get latest pre-release info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases'
$WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
}
catch {
$url = "https://github.com/Romanitho/Winget-AutoUpdate/releases"
$link = ((Invoke-WebRequest $url -UseBasicParsing).Links.href -match "/Winget-AutoUpdate/releases/tag/v*")[0]
$WAUAvailableVersion = $link.Trim().Split("v")[-1]
}
} }
else { else {
#Get latest stable info try {
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' #Get latest stable info
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
$WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
}
catch {
$url = "https://github.com/Romanitho/Winget-AutoUpdate/releases/latest"
$link = ((Invoke-WebRequest $url -UseBasicParsing).Links.href -match "/Winget-AutoUpdate/releases/tag/v*")[0]
$WAUAvailableVersion = $link.Trim().Split("v")[-1]
}
} }
#Return version #Return version
return ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "") return $WAUAvailableVersion
} }