diff --git a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 index bfe0af0..dbf1267 100644 --- a/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUAvailableVersion.ps1 @@ -1,6 +1,13 @@ -function Get-WAUAvailableVersion{ +function Get-WAUAvailableVersion { #Get Github latest version - $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' + if ($true -eq $WAUprerelease) { + #Get latest pre-release info + $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases' + } + else { + #Get latest stable info + $WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' + } $Script:WAULatestVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","") return [version]$WAULatestVersion } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 index 477ac37..b12e609 100644 --- a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 @@ -1,12 +1,23 @@ function Get-WAUUpdateStatus{ - #Get AutoUpdate status + [xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue + + #Check if AutoUpdate is enabled if ($true -eq $UpdateStatus.app.WAUautoupdate){ Write-Log "WAU AutoUpdate is Enabled" "Green" - return $true + $Script:WAUautoupdate = $true + + #Check if pre-release versions are enabled + if ($true -eq $UpdateStatus.app.WAUprerelease){ + Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan" + $Script:WAUprerelease = $true + } + else{ + $Script:WAUprerelease = $false + } } else{ Write-Log "WAU AutoUpdate is Disabled" "Grey" - return $false + $Script:WAUautoupdate = $false } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 1482512..f3551ca 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -25,10 +25,9 @@ function Update-WAU ($VersionToUpdate){ Get-ChildItem -Path $location -Recurse | Unblock-File Write-Log "Unzip finished" "Green" $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path - $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path - if ($TempPath){ - Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force - } + if ($TempPath){ + Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force + } #Remove update zip file Write-Log "Cleaning temp files" diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index c890b25..9de56d8 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -17,9 +17,9 @@ Get-NotifLocale #Check network connectivity if (Test-Network){ #Check if WAU update feature is enabled - $WAUAutoUpdateEnabled = Get-WAUUpdateStatus + Get-WAUUpdateStatus #If yes then check WAU update - if ($WAUAutoUpdateEnabled){ + if ($true -eq $WAUautoupdate){ #Get Current Version $WAUCurrentVersion = Get-WAUCurrentVersion #Get Available Version