Skip to content

Commit b27746a

Browse files
committed
WIP: install script for windows
Signed-off-by: Ayush <mail@ayuch.dev>
1 parent 64e6b38 commit b27746a

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

.goreleaser.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ builds:
1616
goos:
1717
- linux
1818
- darwin # macOS
19+
- windows
1920
goarch:
2021
- amd64 # For Intel/AMD processors
2122
- arm64 # For Apple Silicon and other ARM processors
@@ -29,4 +30,14 @@ archives:
2930
# Files to include in the archive along with the binary.
3031
files:
3132
- LICENSE
32-
- README.md
33+
- README.md
34+
35+
- format: zip
36+
# <-- Add this block for Windows
37+
name_template: >-
38+
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
39+
files:
40+
- LICENSE
41+
- README.md
42+
replacements:
43+
windows: windows

install.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# GitX Windows Installer Script
2+
# Usage: Invoke-WebRequest -Uri "https://raw.githubusercontent.com/gitxtui/gitx/master/install.ps1" -OutFile "install.ps1"; .\install.ps1
3+
4+
$repo = "gitxtui/gitx"
5+
$installDir = "$env:ProgramFiles\gitx"
6+
7+
function Get-Arch {
8+
switch ($env:PROCESSOR_ARCHITECTURE) {
9+
"AMD64" { return "amd64" }
10+
"ARM64" { return "arm64" }
11+
default { Write-Error "Unsupported architecture: $($env:PROCESSOR_ARCHITECTURE)"; exit 1 }
12+
}
13+
}
14+
15+
function Get-LatestRelease {
16+
$apiUrl = "https://api.github.com/repos/$repo/releases"
17+
$response = Invoke-RestMethod -Uri $apiUrl
18+
if ($response -is [System.Collections.IEnumerable] -and $response.Count -gt 0) {
19+
return $response[0].tag_name
20+
} else {
21+
Write-Error "Could not find any release version for $repo."
22+
exit 1
23+
}
24+
}
25+
26+
function Main {
27+
$os = "windows"
28+
$arch = Get-Arch
29+
$version = Get-LatestRelease
30+
$versionNum = $version -replace "^v", ""
31+
$filename = "gitx_${versionNum}_${os}_${arch}.zip"
32+
$downloadUrl = "https://github.com/$repo/releases/download/$version/$filename"
33+
34+
Write-Host "Downloading gitx $version for $os/$arch..."
35+
$tempDir = New-TemporaryFile | Split-Path
36+
$zipPath = Join-Path $tempDir $filename
37+
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
38+
39+
Write-Host "Extracting..."
40+
Expand-Archive -Path $zipPath -DestinationPath $tempDir
41+
42+
if (!(Test-Path $installDir)) {
43+
New-Item -ItemType Directory -Path $installDir | Out-Null
44+
}
45+
46+
$gitxExe = Get-ChildItem -Path $tempDir -Filter "gitx.exe" -Recurse | Select-Object -First 1
47+
if ($null -eq $gitxExe) {
48+
Write-Error "gitx.exe not found in the archive."
49+
exit 1
50+
}
51+
52+
Copy-Item -Path $gitxExe.FullName -Destination (Join-Path $installDir "gitx.exe") -Force
53+
54+
Write-Host "`ngitx has been installed to $installDir"
55+
Write-Host "Add $installDir to your PATH if not already present."
56+
Write-Host "Run 'gitx.exe' to get started."
57+
}
58+
59+
Main

0 commit comments

Comments
 (0)