-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of relying on `bash` (which may not be installed, such as in alpine images), use POSIX bash. Signed-off-by: JP-Ellis <[email protected]>
- Loading branch information
Showing
3 changed files
with
98 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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 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,97 @@ | ||
#!/bin/sh | ||
# | ||
# Usage: | ||
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh | bash | ||
# or | ||
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh -O- | bash | ||
|
||
# While most shells support `local`, it technically isn't POSIX. This will check | ||
# for `local` and alias it to `typeset` if it doesn't exist. | ||
# shellcheck disable=SC3043 | ||
# If a shell does not support `local`, it will be aliased to | ||
# `typeset`, so this check is not needed. | ||
has_local() { | ||
local _has_local | ||
} | ||
has_local 2>/dev/null || alias local=typeset | ||
|
||
set -o errexit # Exit on error | ||
set -o nounset # Treat unset variables as an error | ||
|
||
# Colours | ||
WHITE_BOLD='\033[1;37m' | ||
RESET='\033[0m' | ||
|
||
detect_osarch() { | ||
case $(uname -sm) in | ||
'Linux x86_64') | ||
os='linux' | ||
arch='x86_64' | ||
ext='' | ||
;; | ||
'Linux aarch64') | ||
os='linux' | ||
arch='aarch64' | ||
ext='' | ||
;; | ||
'Darwin x86' | 'Darwin x86_64') | ||
os='osx' | ||
arch='x86_64' | ||
ext='' | ||
;; | ||
'Darwin arm64') | ||
os='osx' | ||
arch='aarch64' | ||
ext='' | ||
;; | ||
CYGWIN* | MINGW32* | MSYS* | MINGW*) | ||
os="windows" | ||
arch='x86_64' | ||
ext='.exe' | ||
;; | ||
*) | ||
echo "Sorry, you'll need to install the plugin CLI manually." | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
install_pact_plugin_cli() { | ||
[ -f ~/.pact/bin/pact-plugin-cli ] && \ | ||
echo "${WHITE_BOLD}=> Plugin CLI already installed${RESET}" && \ | ||
return | ||
|
||
local version="0.1.2" | ||
detect_osarch | ||
local url="https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${version}/pact-plugin-cli-${os}-${arch}${ext}.gz" | ||
|
||
URL=https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${version}/pact-plugin-cli-${os}-${arch}${ext}.gz | ||
echo "${WHITE_BOLD}=> Installing plugins CLI version '${version}'${RESET}" | ||
echo " - OS: ${os}" | ||
echo " - Arch: ${arch}" | ||
echo " - Version: ${version}" | ||
echo " - URL: ${url}" | ||
echo " - Downloading into: ~/.pact/bin/" | ||
|
||
mkdir -p ~/.pact/bin | ||
curl -sSL $URL | gunzip -c >~/.pact/bin/pact-plugin-cli | ||
chmod +x ~/.pact/bin/pact-plugin-cli | ||
} | ||
|
||
install_matt_plugin() { | ||
[ -d ~/.pact/plugins/matt-0.1.1 ] && \ | ||
echo -e "${WHITE_BOLD}=> MATT plugin already installed${RESET}" && \ | ||
return | ||
|
||
local version="0.1.1" | ||
|
||
echo "${WHITE_BOLD}=> Installing MATT plugin version '${version}'${RESET}" | ||
~/.pact/bin/pact-plugin-cli install | ||
} | ||
|
||
main() { | ||
install_pact_plugin_cli | ||
install_matt_plugin | ||
} | ||
|
||
main |
This file was deleted.
Oops, something went wrong.