전체 설치 스크립트 GitHub 릴리스 에셋 검증 및 폴백 다운로드 방어 로직 적용

This commit is contained in:
mcchae committed 2026-10-31 04:54:34 +09:00
1 parent 5a67e7bbcf
commit b41d2f68f3
21 files changed
+541 -190

No files matched your search

+34 -21
View File
@@ -1,4 +1,4 @@
#Requires -Version 5.1
#Requires -Version 5.1
<#
.SYNOPSIS
Installs bottom(btm) process monitor from GitHub Nightly releases.
@@ -46,8 +46,9 @@ $ErrorActionPreference = 'Stop'
# ────────────────────────────────────────────
# Constants
# ────────────────────────────────────────────
$REPO = "ClementTsang/bottom"
$API_URL = "https://api.github.com/repos/$REPO/releases"
$REPO = "ClementTsang/bottom"
$API_URL = "https://api.github.com/repos/$REPO/releases"
$FALLBACK_TAG = "0.12.3"
# ────────────────────────────────────────────
# Utility functions
@@ -98,25 +99,26 @@ function Get-Platform {
# Get latest Nightly release tag
# ────────────────────────────────────────────
function Get-LatestNightlyTag {
Write-Info "Fetching latest Nightly release from GitHub API..."
Write-Info "Fetching latest release from GitHub API..."
try {
$releases = Invoke-RestMethod -Uri $API_URL -UseBasicParsing `
-Headers @{ 'User-Agent' = 'install-bottom-ps1' }
-Headers @{ 'User-Agent' = 'install-bottom-ps1' } -TimeoutSec 15
$nightly = $releases | Where-Object {
$_.assets -and $_.assets.Count -gt 0 -and
(($_.prerelease -eq $true -and $_.tag_name -like 'nightly-*') -or $_.prerelease -eq $false)
} | Select-Object -First 1
if ($nightly -and $nightly.tag_name) {
return $nightly.tag_name
}
} catch {
Write-Err "Failed to call GitHub API: $_"
Write-Warn "GitHub API lookup failed: $_"
}
# Get first item where prerelease=true and tag_name starts with 'nightly-'
$nightly = $releases | Where-Object {
$_.prerelease -eq $true -and $_.tag_name -like 'nightly-*'
} | Select-Object -First 1
if (-not $nightly) {
Write-Err "Could not find Nightly release."
}
return $nightly.tag_name
Write-Warn "Using fallback release tag: $FALLBACK_TAG"
return $FALLBACK_TAG
}
# ────────────────────────────────────────────
@@ -132,7 +134,7 @@ function Get-DownloadUrl {
# Download, extract & install
# ────────────────────────────────────────────
function Install-Bottom {
param([string]$Url)
param([string]$Url, [string]$FallbackUrl)
# Create temp directory
$tmpDir = Join-Path $env:TEMP "bottom_install_$(Get-Random)"
@@ -143,12 +145,22 @@ function Install-Bottom {
Write-Info "Downloading: $Url"
try {
# Suppress progress bar in PowerShell 5+
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Url -OutFile $zipPath -UseBasicParsing
$ProgressPreference = 'Continue'
} catch {
Write-Err "Download failed: $_"
if ($FallbackUrl -and ($FallbackUrl -ne $Url)) {
Write-Warn "Primary download failed. Retrying with fallback URL: $FallbackUrl"
try {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $FallbackUrl -OutFile $zipPath -UseBasicParsing
$ProgressPreference = 'Continue'
} catch {
Write-Err "Download failed: $_"
}
} else {
Write-Err "Download failed: $_"
}
}
Write-Info "Extracting..."
@@ -220,10 +232,11 @@ function Main {
Write-Info "Detected platform: $triple"
$tag = Get-LatestNightlyTag
Write-Info "Latest Nightly tag: $tag"
Write-Info "Release tag: $tag"
$url = Get-DownloadUrl -Tag $tag -Triple $triple
Install-Bottom -Url $url
$fallbackUrl = Get-DownloadUrl -Tag $FALLBACK_TAG -Triple $triple
Install-Bottom -Url $url -FallbackUrl $fallbackUrl
if ($AddToPath) {
Add-ToUserPath -Dir $InstallDir