Skip stale latest prebuilts in installers
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
This commit is contained in:
+82
@@ -100,6 +100,85 @@ function Release-LatestTagDownloadUrl {
|
||||
return $null
|
||||
}
|
||||
|
||||
function Version-Parts($Value) {
|
||||
[regex]::Matches($Value, "\d+") | ForEach-Object { [int64]$_.Value }
|
||||
}
|
||||
|
||||
function Compare-DoshVersion($Left, $Right) {
|
||||
$leftParts = @(Version-Parts $Left)
|
||||
$rightParts = @(Version-Parts $Right)
|
||||
$width = [Math]::Max($leftParts.Count, $rightParts.Count)
|
||||
for ($i = 0; $i -lt $width; $i++) {
|
||||
$l = if ($i -lt $leftParts.Count) { $leftParts[$i] } else { 0 }
|
||||
$r = if ($i -lt $rightParts.Count) { $rightParts[$i] } else { 0 }
|
||||
if ($l -lt $r) { return -1 }
|
||||
if ($l -gt $r) { return 1 }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function Current-SourceVersion {
|
||||
if (Test-Path "Cargo.toml") {
|
||||
$raw = Get-Content "Cargo.toml" -Raw
|
||||
} else {
|
||||
$web = Repo-WebBase $Repo
|
||||
if (-not $web) {
|
||||
return $null
|
||||
}
|
||||
try {
|
||||
$raw = (Invoke-WebRequest -UseBasicParsing -Uri "$web/raw/branch/main/Cargo.toml").Content
|
||||
}
|
||||
catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
if ($raw -match '(?m)^version = "([^"]+)"') {
|
||||
return $Matches[1]
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Latest-ReleaseTag {
|
||||
$web = Repo-WebBase $Repo
|
||||
if (-not $web) {
|
||||
return $null
|
||||
}
|
||||
try {
|
||||
$response = Invoke-WebRequest -UseBasicParsing -Uri "$web/releases/latest" -MaximumRedirection 5
|
||||
$effective = $null
|
||||
if ($response.BaseResponse.ResponseUri) {
|
||||
$effective = $response.BaseResponse.ResponseUri.AbsoluteUri
|
||||
} elseif ($response.BaseResponse.RequestMessage -and $response.BaseResponse.RequestMessage.RequestUri) {
|
||||
$effective = $response.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
|
||||
}
|
||||
$prefix = "$web/releases/tag/"
|
||||
if ($effective -and $effective.StartsWith($prefix)) {
|
||||
return $effective.Substring($prefix.Length)
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return $null
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Latest-ReleaseIsStale {
|
||||
if ($BinaryUrl -or $BinaryBase -or $BinaryVersion -ne "latest") {
|
||||
return $false
|
||||
}
|
||||
$latest = Latest-ReleaseTag
|
||||
$current = Current-SourceVersion
|
||||
if (-not $latest -or -not $current) {
|
||||
return $false
|
||||
}
|
||||
$latestVersion = $latest.TrimStart("v")
|
||||
if ((Compare-DoshVersion $latestVersion $current) -lt 0) {
|
||||
Write-Warning "latest release $latestVersion is older than source $current; skipping stale prebuilt"
|
||||
return $true
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
||||
function Verify-ArchiveChecksum($Url, $Archive) {
|
||||
$checksumPath = "$Archive.sha256"
|
||||
try {
|
||||
@@ -160,6 +239,9 @@ $configDir = Join-Path $HOME ".config\dosh"
|
||||
New-Item -ItemType Directory -Force -Path $bindir, $configDir | Out-Null
|
||||
|
||||
function Install-Prebuilt {
|
||||
if (Latest-ReleaseIsStale) {
|
||||
return $false
|
||||
}
|
||||
$url = Release-LatestTagDownloadUrl
|
||||
if (-not $url) {
|
||||
$url = Release-DownloadUrl
|
||||
|
||||
Reference in New Issue
Block a user