-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
68 lines (55 loc) Β· 2.38 KB
/
Copy pathinstall.ps1
File metadata and controls
68 lines (55 loc) Β· 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Fledge installer for Windows (PowerShell)
# Usage: irm https://raw.githubusercontent.com/CorvidLabs/fledge/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "CorvidLabs/fledge"
function Get-LatestVersion {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -UseBasicParsing
return $release.tag_name
}
function Get-Artifact {
$arch = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq [System.Runtime.InteropServices.Architecture]::Arm64) {
"aarch64"
} else {
"x86_64"
}
return "fledge-windows-$arch.exe"
}
$version = Get-LatestVersion
if (-not $version) {
Write-Error "Could not determine latest version."
exit 1
}
$artifact = Get-Artifact
$installDir = if ($env:FLEDGE_INSTALL_DIR) { $env:FLEDGE_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA "fledge" }
Write-Host " Installing fledge $version..." -ForegroundColor Cyan
if (-not (Test-Path $installDir)) {
New-Item -ItemType Directory -Path $installDir -Force | Out-Null
}
$url = "https://github.com/$Repo/releases/download/$version/$artifact"
$checksumUrl = "$url.sha256"
$tmpFile = Join-Path $env:TEMP "fledge-download.exe"
Write-Host " Downloading $url"
Invoke-WebRequest -Uri $url -OutFile $tmpFile -UseBasicParsing
try {
$expectedHash = (Invoke-WebRequest -Uri $checksumUrl -UseBasicParsing).Content.Trim().Split(" ")[0]
$actualHash = (Get-FileHash -Path $tmpFile -Algorithm SHA256).Hash.ToLower()
if ($actualHash -ne $expectedHash) {
Remove-Item $tmpFile -Force
Write-Error "Checksum mismatch! Expected: $expectedHash, Got: $actualHash"
exit 1
}
Write-Host " Checksum verified." -ForegroundColor Green
} catch {
Write-Host " Warning: Could not verify checksum (continuing anyway)." -ForegroundColor Yellow
}
$dest = Join-Path $installDir "fledge.exe"
Move-Item -Path $tmpFile -Destination $dest -Force
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($userPath -notlike "*$installDir*") {
[Environment]::SetEnvironmentVariable("PATH", "$userPath;$installDir", "User")
Write-Host " Added $installDir to user PATH." -ForegroundColor Green
Write-Host " Restart your terminal for PATH changes to take effect."
}
Write-Host ""
Write-Host " Installed fledge $version to $dest" -ForegroundColor Green
Write-Host " Run 'fledge --help' to get started."