Skip to content

Commit

Permalink
Update install script and readme for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
laureanray committed Jul 17, 2022
1 parent 02bb4fa commit 378e503
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ Shell Installation (Mac, Linux)
curl -fsSL https://raw.githubusercontent.com/laureanray/clibgen/main/install.sh | sh
```

PowerShell Installation (Work in progress)
PowerShell Installation (Windows)
```powershell
iwr https://raw.githubusercontent.com/laureanray/clibgen/main/install.sh -useb | iex
```

Manual Installation (Binaries)
- Download the file for your platform and version you need in the [releases page](https://github.com/laureanray/clibgen/releases)
- Extract to where you store your binaries
- Add the binaries directory to your PATH

### Usage

Expand Down
54 changes: 54 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env pwsh
# Copyright 2022 Laurean Ray Bahala. All rights reserved. MIT license.
# TODO(everyone): Keep this script simple and easily auditable.

$ErrorActionPreference = 'Stop'

if ($v) {
$Version = "v${v}"
}
if ($args.Length -eq 1) {
$Version = $args.Get(0)
}

$ClibgenInstall = $env:CLIBGEN_INSTALL
$BinDir = if ($ClibgenInstall) {
"$ClibgenInstall\bin"
} else {
"$Home\.clibgen\bin"
}

$ClibgenZip = "$BinDir\clibgen.zip"
$ClibgenExe = "$BinDir\clibgen.exe"
$Target = 'Windows-x86_64'

# GitHub requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$ClibgenUri = if (!$Version) {
"https://github.com/laureanray/clibgen/releases/latest/download/clibgen_${Target}.zip"
} else {
"https://github.com/laureanray/clibgen/releases/download/${Version}/clibgen_${Target}.zip"
}

Write-Output $ClibgenUri

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

curl.exe -Lo $ClibgenZip $ClibgenUri

tar.exe xf $ClibgenZip -C $BinDir

Remove-Item $ClibgenZip

$User = [EnvironmentVariableTarget]::User
$Path = [Environment]::GetEnvironmentVariable('Path', $User)
if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) {
[Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User)
$Env:Path += ";$BinDir"
}

Write-Output "Clibgen was installed successfully to $ClibgenExe"
Write-Output "Run 'clibgen --help' to get started"

0 comments on commit 378e503

Please sign in to comment.