Skip to content

Commit

Permalink
add install from powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 3, 2021
1 parent f33e72a commit 422b05b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 17 deletions.
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ SOURCE CODE:
https://github.com/whatchanged-community/whatchanged
```

### Installation
### Install

#### Install via shell
Shell(Mac/Linux)

If you are using Linux/macOS. you can install it with the following command:

```shell
```bash
# install latest version
curl -fsSL https://raw.githubusercontent.com/whatchanged-community/whatchanged/master/install.sh | bash
# or install specified version
Expand All @@ -133,28 +131,24 @@ curl -fsSL https://raw.githubusercontent.com/whatchanged-community/whatchanged/m
curl -sf https://gobinaries.com/whatchanged-community/[email protected] | sh
```

#### Install from Github release page

Download the executable file for your platform at [release page](https://github.com/whatchanged-community/whatchanged/releases) and put the executable file to `$PATH` then try it.
PowerShell (Windows):

```bash
$ whatchanged --help
iwr https://github.com/whatchanged-community/whatchanged/raw/master/install.ps1 -useb | iex
```

### Build from source code
Github release page(All platforms)

Make sure you have `[email protected]` and [goreleaser](https://github.com/goreleaser/goreleaser) installed.
Download the executable file for your platform at [release page](https://github.com/whatchanged-community/whatchanged/releases) and put the executable file to `$PATH` then try the following command:

```shell
$ git clone https://github.com/whatchanged-community/whatchanged.git $GOPATH/src/github.com/whatchanged-community/whatchanged
$ cd $GOPATH/src/github.com/whatchanged-community/whatchanged
$ make build
```bash
$ whatchanged --help
```

### Test
Build and install from source using [Golang](https://golang.org):

```bash
$ make test
go install github.com/whatchanged-community/[email protected]
```

### FAQ
Expand Down
61 changes: 61 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env pwsh
# inherit from https://deno.land/x/[email protected]/install.ps1
# Copyright 2018 the Deno authors. All rights reserved. MIT license.

$ErrorActionPreference = 'Stop'

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

if (Test-Path C:\Windows\SysNative) {
$arch = "amd64"
} else {
$arch = "386"
}

$BinDir = "$Home\bin"
$is64Bit = Test-Path C:\Windows\SysNative
$WhatchangedTarGz = "$BinDir\whatchanged.tar.gz"
$WhatchangedExe = "$BinDir\whatchanged.exe"
$Target = "windows_$arch"

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

$ResourceUri = if (!$Version) {
"https://github.com/whatchanged-community/whatchanged/releases/latest/download/whatchanged_${Target}.tar.gz"
} else {
"https://github.com/whatchanged-community/whatchanged/releases/download/${Version}/whatchanged_${Target}.tar.gz"
}

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

Invoke-WebRequest $ResourceUri -OutFile $WhatchangedTarGz -UseBasicParsing

if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) {
Expand-Archive $WhatchangedTarGz -Destination $BinDir -Force
} else {
if (Test-Path $WhatchangedExe) {
Remove-Item $WhatchangedExe
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($WhatchangedTarGz, $BinDir)
}

Remove-Item $WhatchangedTarGz

$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 "Whatchanged was installed successfully to $WhatchangedExe"
Write-Output "Run 'whatchanged --help' to get started"

0 comments on commit 422b05b

Please sign in to comment.