From e3098f22251df9dcecd737eca464178aa028328b Mon Sep 17 00:00:00 2001 From: fourbroad Date: Sun, 5 Jul 2026 13:45:03 +0800 Subject: [PATCH] ci: sync from octopus@0.15.0 --- install.ps1 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index e2ed669..620f205 100644 --- a/install.ps1 +++ b/install.ps1 @@ -96,13 +96,16 @@ function Install-Octopus { try { $null = Invoke-WebRequest -Uri $releaseUrl -Method Head -UseBasicParsing -ErrorAction Stop } catch { - throw "Release v$specificVersion not found. Available releases: $baseUrl/$REPO/releases" + Write-Color "Error: Release v$specificVersion not found." "Red" + Write-Color "Available releases: $baseUrl/$REPO/releases" "DarkGray" + exit 1 } } else { Write-Color "Fetching latest version..." "DarkGray" $specificVersion = Get-LatestVersion if (-not $specificVersion) { - throw "Failed to fetch latest version." + Write-Color "Error: Failed to fetch latest version." "Red" + exit 1 } } @@ -113,7 +116,7 @@ function Install-Octopus { $installedVersion = & $existing --version 2>$null if ($installedVersion -eq $specificVersion) { Write-Color "Version $specificVersion already installed." "DarkGray" - return + exit 0 } else { Write-Color "Installed version: $installedVersion" "DarkGray" } @@ -141,8 +144,10 @@ function Install-Octopus { $ProgressPreference = "SilentlyContinue" Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing } catch { + Write-Color "Error: Failed to download $downloadUrl" "Red" + Write-Color $_.Exception.Message "Red" Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue - throw "Failed to download $downloadUrl : $($_.Exception.Message)" + exit 1 } # Extract @@ -152,8 +157,9 @@ function Install-Octopus { New-Item -ItemType Directory -Path $INSTALL_DIR -Force | Out-Null $exeSrc = Join-Path $tmpDir "$APP.exe" if (-not (Test-Path $exeSrc)) { + Write-Color "Error: $APP.exe not found in archive." "Red" Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue - throw "$APP.exe not found in archive." + exit 1 } Copy-Item -Path $exeSrc -Destination (Join-Path $INSTALL_DIR "$APP.exe") -Force Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue