grokkit/scripts/grokkit-install.ps1
Gregory Gauthier 2bfd8bd15f
All checks were successful
CI / Test (push) Successful in 37s
CI / Lint (push) Successful in 23s
CI / Build (push) Successful in 19s
Release / Create Release (push) Successful in 34s
feat(install): add PowerShell installer and update README installation docs
- Introduced grokkit-install.ps1 for Windows, mirroring bash installer with auto-detection, checksum verification, and safe installation
- Updated README with one-line and download-first install methods for Bash and PowerShell
- Added Windows-specific notes, improved formatting, tables, and examples in README
- Ensured cross-platform consistency in installation instructions
2026-03-30 11:47:19 +01:00

81 lines
2.7 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<#
.SYNOPSIS
Grokkit Windows installer (PowerShell)
.DESCRIPTION
Downloads, verifies checksum, extracts, and installs grokkit.exe.
Mirrors the hardened grokkit-install.sh exactly.
#>
$ErrorActionPreference = 'Stop'
$VERSION = $env:VERSION
if (-not $VERSION) {
Write-Error "❌ VERSION environment variable not set. Example: `$env:VERSION='0.3.3'; ./grokkit-install.ps1"
exit 1
}
# Strip leading 'v' if present
$VERSION = $VERSION.TrimStart('v')
$GITEA_BASE = "https://repos.gmgauthier.com/gmgauthier/grokkit"
# Platform detection (Windows only supports amd64 for now; arm64 ready for future)
$ARCH = "amd64"
if ($env:PROCESSOR_ARCHITECTURE -like "*ARM*") {
$ARCH = "arm64"
}
$ASSET = "grokkit-windows-${ARCH}-v${VERSION}.tar.gz"
Write-Host "Installing grokkit ${VERSION} for windows/${ARCH}..."
$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString())
New-Item -ItemType Directory -Path $TempDir | Out-Null
try {
Push-Location $TempDir
# Download asset + checksums
Write-Host "Downloading ${ASSET}..."
Invoke-WebRequest -Uri "${GITEA_BASE}/releases/download/v${VERSION}/${ASSET}" -OutFile "asset.tar.gz"
Write-Host "Downloading checksums.txt..."
Invoke-WebRequest -Uri "${GITEA_BASE}/releases/download/v${VERSION}/checksums.txt" -OutFile "checksums.txt"
# Robust checksum verification
Write-Host "Verifying checksum..."
$ChecksumContent = Get-Content "checksums.txt" -Raw
$HashLine = $ChecksumContent -split "`n" | Where-Object { $_ -match $ASSET }
if ($HashLine) {
$ExpectedHash = ($HashLine -split '\s+')[0]
$ActualHash = (Get-FileHash "asset.tar.gz" -Algorithm SHA256).Hash.ToLower()
if ($ActualHash -ne $ExpectedHash) {
Write-Error "❌ Checksum mismatch for ${ASSET}!"
exit 1
}
Write-Host "✅ Checksum verified successfully"
}
else {
Write-Warning "⚠️ No checksum entry found for ${ASSET} continuing without verification"
}
# Extract (modern Windows has tar.exe)
Write-Host "Extracting asset..."
tar -xzf "asset.tar.gz"
# The binary inside is named grokkit-windows-amd64.exe (per release workflow)
$BinaryName = "grokkit-windows-${ARCH}.exe"
# Install
$InstallDir = Join-Path $env:USERPROFILE ".local\bin"
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
Move-Item $BinaryName "${InstallDir}\grokkit.exe" -Force
Write-Host "✅ grokkit ${VERSION} installed to ${InstallDir}\grokkit.exe"
Write-Host "Add to PATH if needed: `$env:PATH += `";${InstallDir}`""
& "${InstallDir}\grokkit.exe" version
}
finally {
Pop-Location
Remove-Item -Recurse -Force $TempDir -ErrorAction SilentlyContinue
}