-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall.ps1
More file actions
56 lines (44 loc) · 2.01 KB
/
install.ps1
File metadata and controls
56 lines (44 loc) · 2.01 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
# icm installer for Windows - https://github.com/rtk-ai/icm
# Usage: irm https://raw.githubusercontent.com/rtk-ai/icm/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "rtk-ai/icm"
$BinaryName = "icm"
function Get-Arch {
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
switch ($arch) {
"X64" { return "x86_64" }
default { throw "Unsupported architecture: $arch. Only x86_64 is supported on Windows." }
}
}
function Get-LatestVersion {
$release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
return $release.tag_name
}
$Arch = Get-Arch
$Version = Get-LatestVersion
$Target = "$Arch-pc-windows-msvc"
$InstallDir = Join-Path $env:LOCALAPPDATA "icm\bin"
Write-Host "[INFO] Installing $BinaryName $Version ($Arch)..." -ForegroundColor Green
# Create install directory
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
# Download
$Url = "https://github.com/$Repo/releases/download/$Version/$BinaryName-$Target.zip"
$TempZip = Join-Path $env:TEMP "$BinaryName.zip"
Write-Host "[INFO] Downloading from: $Url" -ForegroundColor Green
Invoke-WebRequest -Uri $Url -OutFile $TempZip
# Extract
$TempDir = Join-Path $env:TEMP "$BinaryName-extract"
if (Test-Path $TempDir) { Remove-Item -Recurse -Force $TempDir }
Expand-Archive -Path $TempZip -DestinationPath $TempDir
Copy-Item (Join-Path $TempDir "$BinaryName.exe") -Destination $InstallDir -Force
# Cleanup
Remove-Item $TempZip -Force
Remove-Item $TempDir -Recurse -Force
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
Write-Host "[INFO] Added $InstallDir to user PATH (restart terminal to apply)" -ForegroundColor Yellow
}
Write-Host "[INFO] Successfully installed to $InstallDir\$BinaryName.exe" -ForegroundColor Green
Write-Host "[INFO] Run '$BinaryName --help' to get started." -ForegroundColor Green