From 10185e6835eb08d393b048ab8a65057bde77d1af Mon Sep 17 00:00:00 2001 From: Anoop Gopalakrishnan Date: Wed, 31 Jan 2024 21:05:04 -0800 Subject: [PATCH] bug: Fix the powershell install - picks binaries from github releases Signed-off-by: Anoop Gopalakrishnan --- static/script/install.ps1 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/static/script/install.ps1 b/static/script/install.ps1 index 29d94b4eaa2..a3d7bddae2d 100755 --- a/static/script/install.ps1 +++ b/static/script/install.ps1 @@ -16,7 +16,8 @@ $VelaCliBuildNameLegacy = "vela" $VelaCliBuildName = "vela.exe" $VelaCliFileName = "vela.exe" $VelaCliFilePath = "${VelaRoot}\${VelaCliFileName}" -$RemoteURL = "https://static.kubevela.net/binary/vela" +$VersionCheckURL = "https://api.github.com/repos/kubevela/kubevela" +$RemoteURL = "https://github.com/kubevela/kubevela/releases/download" if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') { Write-Output "PowerShell requires an execution policy of 'RemoteSigned'." @@ -49,13 +50,20 @@ if (!(Test-Path $VelaRoot -PathType Container)) { $os_arch = "windows-amd64" $vela_cli_filename = "vela" if (!$Version) { - $Version = Invoke-RestMethod -Headers $githubHeader -Uri "${RemoteURL}/latest_version" -Method Get - $Version = $Version.Trim() -} -if (!$Version.startswith("v")) { - $Version = "v" + $Version + $response = Invoke-RestMethod -Headers $githubHeader -Uri "${VersionCheckURL}/releases/latest" -Method Get + $latestRelease = $response.tag_name + if (!$latestRelease) { + Write-Error "Error: Unable to retrieve the latest version." + exit 1 + } + + if (!$latestRelease.StartsWith("v")) { + $latestRelease = "v" + $latestRelease + } + $Version = $latestRelease } + $assetName = "${vela_cli_filename}-${Version}-${os_arch}.zip" $zipFileUrl = "${RemoteURL}/${Version}/${assetName}"