Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ builds:
goos:
- linux
- darwin # macOS
- windows
goarch:
- amd64 # For Intel/AMD processors
- arm64 # For Apple Silicon and other ARM processors
Expand All @@ -29,4 +30,14 @@ archives:
# Files to include in the archive along with the binary.
files:
- LICENSE
- README.md
- README.md

# zip format to support installation for windows
- format: zip
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
files:
- LICENSE
- README.md
replacements:
windows: windows
59 changes: 59 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# GitX Windows Installer Script
# Usage: Invoke-WebRequest -Uri "https://raw.githubusercontent.com/gitxtui/gitx/master/install.ps1" -OutFile "install.ps1"; .\install.ps1

$repo = "gitxtui/gitx"
$installDir = "$env:ProgramFiles\gitx"

function Get-Arch {
switch ($env:PROCESSOR_ARCHITECTURE) {
"AMD64" { return "amd64" }
"ARM64" { return "arm64" }
default { Write-Error "Unsupported architecture: $($env:PROCESSOR_ARCHITECTURE)"; exit 1 }
}
}

function Get-LatestRelease {
$apiUrl = "https://api.github.com/repos/$repo/releases"
$response = Invoke-RestMethod -Uri $apiUrl
if ($response -is [System.Collections.IEnumerable] -and $response.Count -gt 0) {
return $response[0].tag_name
} else {
Write-Error "Could not find any release version for $repo."
exit 1
}
}

function Main {
$os = "windows"
$arch = Get-Arch
$version = Get-LatestRelease
$versionNum = $version -replace "^v", ""
$filename = "gitx_${versionNum}_${os}_${arch}.zip"
$downloadUrl = "https://github.com/$repo/releases/download/$version/$filename"

Write-Host "Downloading gitx $version for $os/$arch..."
$tempDir = New-TemporaryFile | Split-Path
$zipPath = Join-Path $tempDir $filename
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath

Write-Host "Extracting..."
Expand-Archive -Path $zipPath -DestinationPath $tempDir

if (!(Test-Path $installDir)) {
New-Item -ItemType Directory -Path $installDir | Out-Null
}

$gitxExe = Get-ChildItem -Path $tempDir -Filter "gitx.exe" -Recurse | Select-Object -First 1
if ($null -eq $gitxExe) {
Write-Error "gitx.exe not found in the archive."
exit 1
}

Copy-Item -Path $gitxExe.FullName -Destination (Join-Path $installDir "gitx.exe") -Force

Write-Host "`ngitx has been installed to $installDir"
Write-Host "Add $installDir to your PATH if not already present."
Write-Host "Run 'gitx.exe' to get started."
}

Main