Fix installer downloads for specific releases (#1976)

* Fix installer downloads for specific releases

Github download urls for a specific release uses the pattern `../releases/download/[RELEASE]/..`, which differs from the latest release URL which uses `../releases/latest/download/..`.

For convenience, if `BINSTALL_VERSION` is set but doesn't start with `v`, the v is prefixed.

* ci: Set BINSTALL_VERSION in install script tests

When running the install-script workflow in Github Actions, add matrix
options for not setting the variable, setting it to the latest release
with the `v` prefix, and setting it to the latest release without the
`v` prefix.
This commit is contained in:
Martijn Pieters 2024-11-20 08:08:08 +00:00 committed by GitHub
parent 2417642284
commit 266e627928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 65 additions and 5 deletions

View file

@ -2,10 +2,19 @@ $ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
$tmpdir = $Env:TEMP
$BINSTALL_VERSION = $Env:BINSTALL_VERSION
if (-not $BINSTALL_VERSION) {
$BINSTALL_VERSION = 'latest'
if ($BINSTALL_VERSION -and $BINSTALL_VERSION -notlike 'v*') {
# prefix version with v
$BINSTALL_VERSION = "v$BINSTALL_VERSION"
}
$base_url = "https://github.com/cargo-bins/cargo-binstall/releases/$BINSTALL_VERSION/download/cargo-binstall-"
# Fetch binaries from `[..]/releases/latest/download/[..]` if _no_ version is
# given, otherwise from `[..]/releases/download/VERSION/[..]`. Note the shifted
# location of '/download'.
$base_url = if (-not $BINSTALL_VERSION) {
"https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-"
} else {
"https://github.com/cargo-bins/cargo-binstall/releases/download/$BINSTALL_VERSION/cargo-binstall-"
}
$proc_arch = [Environment]::GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", [EnvironmentVariableTarget]::Machine)
if ($proc_arch -eq "AMD64") {
$arch = "x86_64"