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}"