-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-from-release.ps1
More file actions
66 lines (50 loc) · 2.23 KB
/
install-from-release.ps1
File metadata and controls
66 lines (50 loc) · 2.23 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
# cutl Windows PowerShell Installer
# Downloads and installs the latest cutl CLI release for Windows
$ErrorActionPreference = "Stop"
Write-Host "Installing cutl CLI for Windows..." -ForegroundColor Cyan
# Detect architecture
$arch = if ([Environment]::Is64BitOperatingSystem) { "x86_64" } else { "i686" }
$platform = "windows-$arch"
# Installation directory
$installDir = "$env:LOCALAPPDATA\cutl\bin"
Write-Host "Install directory: $installDir"
# Create directory if it doesn't exist
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
# Fetch latest release info
Write-Host "Fetching latest release..."
$releaseUrl = "https://api.github.com/repos/ragilhadi/cutl/releases/latest"
$release = Invoke-RestMethod -Uri $releaseUrl
$version = $release.tag_name
Write-Host "Latest version: $version"
# Find the Windows asset
$assetName = "cutl-$platform.zip"
$asset = $release.assets | Where-Object { $_.name -eq $assetName }
if (-not $asset) {
Write-Host "Error: Could not find $assetName in release assets" -ForegroundColor Red
exit 1
}
$downloadUrl = $asset.browser_download_url
Write-Host "Downloading from: $downloadUrl"
# Download the archive
$zipPath = "$env:TEMP\cutl-$platform.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
# Extract
Write-Host "Extracting..."
Expand-Archive -Path $zipPath -DestinationPath $env:TEMP -Force
# Move binary to install directory
Move-Item -Path "$env:TEMP\cutl.exe" -Destination "$installDir\cutl.exe" -Force
# Clean up
Remove-Item -Path $zipPath -Force
Write-Host "`n✓ Installed to $installDir\cutl.exe" -ForegroundColor Green
# Check if directory is in PATH
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
Write-Host "`n⚠️ WARNING: $installDir is not in your PATH" -ForegroundColor Yellow
Write-Host "`nTo add it to your PATH, run this command in PowerShell (as Administrator):"
Write-Host " [Environment]::SetEnvironmentVariable('Path', `$env:Path + ';$installDir', 'User')" -ForegroundColor Cyan
Write-Host "`nThen restart your terminal."
} else {
Write-Host "`n✓ $installDir is already in your PATH" -ForegroundColor Green
}
Write-Host "`nInstallation complete! Run: cutl --help"
Write-Host "Version: $version"