Repository navigation
Add install scripts #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add install scripts #148
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8f2eece
Add wpm install scripts
thelovekesh f9ed455
Add install dir
thelovekesh 6dd1212
Update binary docker image to have certs
thelovekesh 0eed0e2
Update web client
thelovekesh be3281f
Fix arch requirement for rosetta 2
thelovekesh b619d1e
Remove redundant rm logic
thelovekesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,5 +18,6 @@ | |
| !cli | ||
| !cmd | ||
| !pkg | ||
| !install | ||
| !.github | ||
| !scripts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Usage: | ||
| # powershell -ExecutionPolicy ByPass -File install.ps1 | ||
| # powershell -ExecutionPolicy ByPass -File install.ps1 -Version v1.0.0 | ||
|
|
||
| param ( | ||
| [string]$Version | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
| Set-StrictMode -Version Latest | ||
|
|
||
| function Show-Error { param([string]$Msg); Write-Host "error: $Msg" -ForegroundColor Red } | ||
| function Show-Success { param([string]$Msg); Write-Host "$Msg" -ForegroundColor Green } | ||
| function Show-Info { param([string]$Msg); Write-Host "$Msg" -ForegroundColor Gray } | ||
| function Show-Bold { param([string]$Msg); Write-Host "$Msg" -ForegroundColor White } | ||
|
|
||
| $Arch = $env:PROCESSOR_ARCHITECTURE | ||
| $Target = "" | ||
|
|
||
| if ($Arch -eq "AMD64") { | ||
| $Target = "windows-amd64" | ||
| } elseif ($Arch -eq "ARM64") { | ||
| $Target = "windows-arm64" | ||
| } else { | ||
| Show-Error "Unsupported architecture: $Arch" | ||
| exit 1 | ||
| } | ||
|
|
||
| $GitHubOrg = "trywpm" | ||
| $Repo = "cli" | ||
| $ExeName = "wpm.exe" | ||
| # Install to %LocalAppData%\wpm (Standard user-level location) | ||
| $InstallDir = Join-Path $env:LOCALAPPDATA "wpm" | ||
| $ExePath = Join-Path $InstallDir $ExeName | ||
|
|
||
| $BaseUrl = "https://github.com/$GitHubOrg/$Repo/releases" | ||
| $BinaryName = "wpm-$Target.exe" | ||
|
|
||
| if ([string]::IsNullOrEmpty($Version)) { | ||
| $Uri = "$BaseUrl/latest/download/$BinaryName" | ||
| } else { | ||
| $Uri = "$BaseUrl/download/$Version/$BinaryName" | ||
| } | ||
|
|
||
| try { | ||
| Show-Info "Installing wpm for $Target..." | ||
|
|
||
| if (-not (Test-Path $InstallDir)) { | ||
| New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null | ||
| } | ||
|
|
||
| Show-Info "Downloading from $Uri..." | ||
| Invoke-WebRequest -Uri $Uri -OutFile $ExePath | ||
|
|
||
| # Check if InstallDir is in the User's persistent Path | ||
| $UserPathArgs = "Path", "User" | ||
| $CurrentPath = [Environment]::GetEnvironmentVariable($UserPathArgs) | ||
|
|
||
| if (($CurrentPath -split ';') -notcontains $InstallDir) { | ||
| Show-Info "Adding $InstallDir to User PATH..." | ||
|
|
||
| # Add to persistent Registry PATH | ||
| [Environment]::SetEnvironmentVariable("Path", "$CurrentPath;$InstallDir", "User") | ||
|
|
||
| $env:Path += ";$InstallDir" | ||
| } | ||
|
|
||
| Write-Host "" | ||
| Show-Success "wpm installed to $ExePath" | ||
|
|
||
| Write-Host "" | ||
| Show-Info "To get started, run:" | ||
| Write-Host "" | ||
| Show-Bold " wpm --help" | ||
| } catch { | ||
| Show-Error $_.Exception.Message | ||
| exit 1 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Reset | ||
| Color_Off='' | ||
|
|
||
| # Regular Colors | ||
| Red='' | ||
| Green='' | ||
| Dim='' # White | ||
|
|
||
| # Bold | ||
| Bold_White='' | ||
| Bold_Green='' | ||
|
|
||
| if [[ -t 1 ]]; then | ||
| # Reset | ||
| Color_Off='\033[0m' # Text Reset | ||
|
|
||
| # Regular Colors | ||
| Red='\033[0;31m' # Red | ||
| Green='\033[0;32m' # Green | ||
| Dim='\033[0;2m' # White | ||
|
|
||
| # Bold | ||
| Bold_Green='\033[1;32m' # Bold Green | ||
| Bold_White='\033[1m' # Bold White | ||
| fi | ||
|
|
||
| error() { | ||
| echo -e "${Red}error${Color_Off}:" "$@" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| info() { | ||
| echo -e "${Dim}$@ ${Color_Off}" | ||
| } | ||
|
|
||
| info_bold() { | ||
| echo -e "${Bold_White}$@ ${Color_Off}" | ||
| } | ||
|
|
||
| success() { | ||
| echo -e "${Green}$@ ${Color_Off}" | ||
| } | ||
|
|
||
| if [[ $# -gt 1 ]]; then | ||
| error 'Usage: install.sh [version]' | ||
| fi | ||
|
|
||
| platform=$(uname -ms) | ||
|
|
||
| case $platform in | ||
| *'MINGW'* | *'CYGWIN'* | *'MSYS'* | 'Windows_NT'*) | ||
| error "Please run \`powershell -c \"irm wpm.so/install.ps1|iex\"\` to install wpm on Windows systems." | ||
| ;; | ||
| esac | ||
|
|
||
| case $platform in | ||
| # --- macOS --- | ||
| 'Darwin x86_64') | ||
| target="darwin-amd64" | ||
| ;; | ||
| 'Darwin arm64') | ||
| target="darwin-arm64" | ||
| ;; | ||
|
|
||
| # --- Linux --- | ||
| 'Linux x86_64') | ||
| target="linux-amd64" | ||
| ;; | ||
| 'Linux aarch64' | 'Linux arm64') | ||
| target="linux-arm64" | ||
| ;; | ||
| 'Linux armv7'*) | ||
| target="linux-arm-v7" | ||
| ;; | ||
| 'Linux armv6'*) | ||
| target="linux-arm-v6" | ||
| ;; | ||
| 'Linux ppc64le') | ||
| target="linux-ppc64le" | ||
| ;; | ||
| 'Linux riscv64') | ||
| target="linux-riscv64" | ||
| ;; | ||
| 'Linux s390x') | ||
| target="linux-s390x" | ||
| ;; | ||
|
|
||
| # --- Unsupported --- | ||
| *) | ||
| error "Unsupported platform: $platform" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| if [[ $target = darwin-amd64 ]]; then | ||
| # Is this process running in Rosetta? | ||
| # redirect stderr to devnull to avoid error message when not running in Rosetta | ||
| if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) = 1 ]]; then | ||
| target=darwin-arm64 | ||
| info "Your shell is running in Rosetta 2. Downloading wpm for $target instead" | ||
| fi | ||
| fi | ||
|
|
||
| GITHUB=${GITHUB-"https://github.com"} | ||
|
|
||
| github_repo="$GITHUB/trywpm/cli" | ||
|
|
||
| exe_name=wpm | ||
| bin_dir="/usr/local/bin" | ||
| exe="$bin_dir/$exe_name" | ||
|
|
||
| if [[ $# = 0 ]]; then | ||
| wpm_uri=$github_repo/releases/latest/download/wpm-$target | ||
| else | ||
| wpm_uri=$github_repo/releases/download/$1/wpm-$target | ||
| fi | ||
|
|
||
| curl --fail --location --progress-bar --output "/tmp/$exe_name" "$wpm_uri" || | ||
| error "Failed to download wpm from \"$wpm_uri\"" | ||
|
|
||
| chmod +x "/tmp/$exe_name" || | ||
| error 'Failed to make wpm executable' | ||
|
|
||
| sudo mv "/tmp/$exe_name" "$exe" || | ||
| error 'Failed to move extracted wpm to destination' | ||
|
|
||
| echo | ||
| success "wpm installed to ${Bold_Green}$exe${Color_Off}" | ||
|
|
||
| echo | ||
| info "To get started, run:" | ||
| echo | ||
| info_bold " wpm --help" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.