Skip to content

Commit

Permalink
dist: shell installers
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Jul 24, 2022
1 parent 85f7620 commit f5fd175
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
if [[ $platform =~ "windows" ]]; then
exe=".exe"
fi
pkgname=$PROJECT_NAME-$TAG-$platform
pkgname=$PROJECT_NAME-$platform
mkdir tmp/$pkgname
# cp LICENSE README.md tmp/$pkgname
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
Expand Down
52 changes: 52 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env pwsh
# Copyright 2018 the Deno authors. 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)
}

$Install = $env:BP_INSTALL
$BinDir = if ($Install) {
"$Install\bin"
} else {
"$Home\.backpack-bin\bin"
}

$Zip = "$BinDir\backpack.zip"
$Exe = "$BinDir\bp.exe"
$Target = 'x86_64-windows'

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

$Uri = if (!$Version) {
"https://github.com/rusty-ferris-club/backpack/releases/latest/download/backpack-${Target}.zip"
} else {
"https://github.com/rusty-ferris-club/backpack/releases/download/${Version}/backpack-${Target}.zip"
}

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

curl.exe -Lo $Zip $Uri

tar.exe xf $Zip -C $BinDir

Remove-Item $Zip

$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 "Backpack was installed successfully to $Exe"
Write-Output "Run 'bp --help' to get started"
53 changes: 53 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh
# Copyright 2019 the Deno authors. All rights reserved. MIT license.
# TODO(everyone): Keep this script simple and easily auditable.

set -e

if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install Backpack." 1>&2
exit 1
fi

if [ "$OS" = "Windows_NT" ]; then
target="x86_64-windows"
else
case $(uname -sm) in
"Darwin x86_64") target="x86_64-apple-darwin" ;;
"Darwin arm64") target="aarch64-apple-darwin" ;;
*) target="x86_64-unknown-linux-gnu" ;;
esac
fi

if [ $# -eq 0 ]; then
uri="https://github.com/rusty-ferris-club/releases/latest/download/backpack-${target}.zip"
else
uri="https://github.com/rusty-ferris-club/releases/download/${1}/backpack-${target}.zip"
fi

install="${BP_INSTALL:-$HOME/.backpack-bin}"
bin_dir="$install/bin"
exe="$bin_dir/bp"

if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi

curl --fail --location --progress-bar --output "$exe.zip" "$uri"
unzip -d "$bin_dir" -o "$exe.zip"
chmod +x "$exe"
rm "$exe.zip"

echo "Backpack was installed successfully to $exe"
if command -v bp >/dev/null; then
echo "Run 'bp --help' to get started"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export BP_INSTALL=\"$install\""
echo " export PATH=\"\$BP_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi

0 comments on commit f5fd175

Please sign in to comment.