Forked from MarkTiedemann/download-latest-release.ps1
Last active
October 2, 2020 11:33
-
-
Save clifmo/8c359caf41f10de989088e05cfc9ba57 to your computer and use it in GitHub Desktop.
Download latest GitHub release via Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download latest release of Katalon Studio Runtime Engine from github with fallback version. | |
# Includes output for Azure DevOps pipeline tasks | |
$FALLBACK_VERSION = "7.7.1" | |
$repo = "katalon-studio/katalon-studio" | |
$filePrefix = "Katalon_Studio_Engine_Windows_64-" | |
$fileVersion = "" | |
$fileSuffix = ".zip" | |
$releases = "https://api.github.com/repos/$repo/releases" | |
try { | |
Write-Host Determining latest release that is not a release candidate | |
$fileVersion = Invoke-WebRequest $releases | ConvertFrom-Json | Where-Object {$_.tag_name.split(".").length -lt 4} | Select-Object -First 1 | Select-Object -ExpandProperty tag_name | Foreach-object {$_ -replace 'v',''} | |
if ($fileVersion.length -le 0) { | |
Write-Host "##vso[task.LogIssue type=warning;]Using hard-coded version number '7.7.1'. Unable to determine version from GitHub: $releases" | |
$fileVersion = $FALLBACK_VERSION | |
} | |
$filename = $filePrefix+$fileVersion+$fileSuffix | |
#https://github.com/katalon-studio/katalon-studio/releases/download/v7.7.1/Katalon_Studio_Engine_Windows_64-7.7.1.zip | |
$download = "https://github.com/$repo/releases/download/v$fileVersion/$filename" | |
Write-Host Dowloading latest release | |
Invoke-WebRequest $download -Out $filename | |
write-host "Download complete" | |
} catch { | |
Write-host $_.Exception.Message | |
Write-host $_.Exception.StackTrace | |
Write-Host "##vso[task.LogIssue type=error;]Error downloading KRE." | |
} finally { | |
write-host "Leaving download-kre.ps1" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment