Skip to content

Commit ac0966b

Browse files
committed
PowerShell script for Windows users
1 parent 055c99b commit ac0966b

2 files changed

Lines changed: 131 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,22 @@ jobs:
6868
name: Mammouth Code v${{ steps.version.outputs.version }}
6969
draft: false
7070
prerelease: false
71+
files: |
72+
packages/opencode/dist/mammouth-*.tar.gz
73+
packages/opencode/dist/mammouth-*.zip
7174
body: |
7275
## Mammouth Code v${{ steps.version.outputs.version }}
7376
7477
### Installation
7578
76-
**curl (recommended)**
79+
**macOS / Linux (curl)**
7780
```bash
7881
curl -fsSL https://code.mammouth.ai/install.sh | bash
7982
```
83+
84+
**Windows (PowerShell)**
85+
```powershell
86+
irm https://code.mammouth.ai/install.ps1 | iex
87+
```
8088
env:
8189
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

install.ps1

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Mammouth Code Installer for Windows
2+
# Usage: irm https://code.mammouth.ai/install.ps1 | iex
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
$Repo = "mammouth-ai/code"
7+
$BinaryName = "mammouth"
8+
$InstallDir = "$env:USERPROFILE\.mammouth\bin"
9+
10+
function Write-Info { param($Message) Write-Host "[INFO] $Message" -ForegroundColor Green }
11+
function Write-Warn { param($Message) Write-Host "[WARN] $Message" -ForegroundColor Yellow }
12+
function Write-Err { param($Message) Write-Host "[ERROR] $Message" -ForegroundColor Red; exit 1 }
13+
14+
# Detect architecture
15+
function Get-Platform {
16+
$arch = if ([Environment]::Is64BitOperatingSystem) {
17+
switch ($env:PROCESSOR_ARCHITECTURE) {
18+
"ARM64" { "arm64" }
19+
"AMD64" { "x64" }
20+
default { "x64" }
21+
}
22+
} else {
23+
Write-Err "32-bit systems are not supported."
24+
}
25+
26+
return "mammouth-windows-$arch"
27+
}
28+
29+
# Get latest version from GitHub API
30+
function Get-LatestVersion {
31+
if ($env:VERSION) {
32+
return $env:VERSION
33+
}
34+
35+
try {
36+
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -Headers @{ "User-Agent" = "MammouthInstaller" }
37+
$version = $release.tag_name -replace "^v", ""
38+
if (-not $version) {
39+
Write-Err "Failed to determine latest version."
40+
}
41+
return $version
42+
} catch {
43+
Write-Err "Failed to fetch latest release: $_"
44+
}
45+
}
46+
47+
function Install-Mammouth {
48+
$platform = Get-Platform
49+
$version = Get-LatestVersion
50+
51+
Write-Info "Installing Mammouth Code v$version for $platform..."
52+
53+
# Create install directory
54+
if (-not (Test-Path $InstallDir)) {
55+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
56+
}
57+
58+
$downloadUrl = "https://github.com/$Repo/releases/download/v$version/$platform.zip"
59+
$tempDir = Join-Path $env:TEMP "mammouth-install-$(Get-Random)"
60+
$archivePath = Join-Path $tempDir "$platform.zip"
61+
62+
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
63+
64+
Write-Info "Downloading from $downloadUrl..."
65+
try {
66+
Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath -UseBasicParsing
67+
} catch {
68+
Write-Err "Failed to download. Check if the release exists for your platform: $_"
69+
}
70+
71+
Write-Info "Extracting..."
72+
Expand-Archive -Path $archivePath -DestinationPath $tempDir -Force
73+
74+
# Find the binary
75+
$binaryPath = Get-ChildItem -Path $tempDir -Recurse -Filter "$BinaryName.exe" | Select-Object -First 1
76+
if (-not $binaryPath) {
77+
# Bun may produce the binary without .exe extension
78+
$binaryPath = Get-ChildItem -Path $tempDir -Recurse -Filter $BinaryName | Where-Object { -not $_.PSIsContainer } | Select-Object -First 1
79+
}
80+
81+
if (-not $binaryPath) {
82+
Write-Err "Binary not found in archive."
83+
}
84+
85+
$destPath = Join-Path $InstallDir "$BinaryName.exe"
86+
Copy-Item -Path $binaryPath.FullName -Destination $destPath -Force
87+
88+
# Cleanup
89+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
90+
91+
Write-Info "Installed to $destPath"
92+
93+
# Add to PATH
94+
Add-ToPath
95+
}
96+
97+
function Add-ToPath {
98+
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
99+
100+
if ($currentPath -like "*\.mammouth\bin*") {
101+
Write-Info "Mammouth Code is ready! Run 'mammouth' to get started."
102+
return
103+
}
104+
105+
$newPath = "$InstallDir;$currentPath"
106+
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
107+
108+
# Also update current session
109+
$env:Path = "$InstallDir;$env:Path"
110+
111+
Write-Info "Added to user PATH."
112+
Write-Host ""
113+
Write-Info "Installation complete!"
114+
Write-Host ""
115+
Write-Host "To start using Mammouth Code, either:"
116+
Write-Host " 1. Open a new terminal, or"
117+
Write-Host " 2. Run: `$env:Path = '$InstallDir;' + `$env:Path"
118+
Write-Host ""
119+
Write-Host "Then run: mammouth"
120+
}
121+
122+
Install-Mammouth

0 commit comments

Comments
 (0)