wingetautoupdate/Sources/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1

42 lines
1.4 KiB
PowerShell
Raw Normal View History

#Function to get the latest WAU available version on Github
function Get-WAUAvailableVersion {
#Get Github latest version
if ($WAUConfig.WAU_UpdatePrerelease -eq 1) {
#Log
Write-ToLog "WAU AutoUpdate Pre-release versions is Enabled" "Cyan"
try {
#Get latest pre-release info
2024-09-17 10:07:28 +00:00
$WAUurl = "https://api.github.com/repos/Romanitho/$GitHub_Repo/releases"
$WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
}
catch {
2024-09-17 10:07:28 +00:00
$url = "https://github.com/Romanitho/$GitHub_Repo/releases"
$link = ((Invoke-WebRequest $url -UseBasicParsing).Links.href -match "/$GitHub_Repo/releases/tag/v*")[0]
$WAUAvailableVersion = $link.Trim().Split("v")[-1]
}
}
else {
try {
#Get latest stable info
2024-09-17 10:07:28 +00:00
$WAUurl = "https://api.github.com/repos/Romanitho/$GitHub_Repo/releases/latest"
$WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
}
catch {
2024-09-17 10:07:28 +00:00
$url = "https://github.com/Romanitho/$GitHub_Repo/releases/latest"
$link = ((Invoke-WebRequest $url -UseBasicParsing).Links.href -match "/$GitHub_Repo/releases/tag/v*")[0]
$WAUAvailableVersion = $link.Trim().Split("v")[-1]
}
}
#Return version
return $WAUAvailableVersion
2024-09-02 14:10:21 +00:00
}