diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 97b48c2..cceb9b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,6 +26,18 @@ jobs: with: name: build path: build/ + test-install-script: + name: Test install script + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Install dependencies + run: sudo apt-get install -y fzf + - name: Test install script + run: | + curl -sSLf https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/install.sh | sh -s -- --url "https://github.com/mads-bisgaard/bayesh/releases/download/v0.0.1/bayesh-v0.0.1-linux-amd64.tar.gz" + bayesh --version bats-tests: name: Bats tests runs-on: ubuntu-latest diff --git a/README.md b/README.md index a82ebc6..fc89fce 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Bayesh is the auto-suggestion feature on your phone when you write messages — 2. **Install Bayesh:** To install Bayesh run ```sh - curl -sL https://raw.githubusercontent.com/mads-bisgaard/bayesh/refs/heads/main/install.sh | bash + curl -sSLf https://raw.githubusercontent.com/mads-bisgaard/bayesh/refs/heads/main/install.sh | sh ``` 3. **Go!** diff --git a/install.sh b/install.sh index ee46c61..fc01909 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,10 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e -set -o pipefail version=v0.0.1 _sudo="sudo" -command -v sudo &> /dev/null || _sudo="" +command -v sudo > /dev/null 2>&1 || _sudo="" target_dir="/usr/local/bin" [ -d "$target_dir" ] || target_dir="/usr/bin" [ -d "$target_dir" ] || { echo "- Error: Could not find /usr/local/bin nor /usr/bin directories." >&2; exit 1; } @@ -24,7 +23,7 @@ case "$arch" in ;; esac -function _usage() { +_usage() { echo "Usage: install.sh [--help] [--url ]" echo "Install Bayesh." echo "Options:" @@ -34,7 +33,7 @@ function _usage() { } url="https://github.com/mads-bisgaard/bayesh/releases/download/${version}/bayesh-${version}-linux-${goarch}.tar.gz" -while [[ $# -gt 0 ]]; do +while [ $# -gt 0 ]; do case $1 in --help) _usage @@ -52,22 +51,22 @@ while [[ $# -gt 0 ]]; do done -function _check_dependency() { - command -v "$1" &> /dev/null || { echo "- Error: Required dependency $1 is not installed." >&2; exit 1; } +_check_dependency() { + command -v "$1" > /dev/null 2>&1 || { echo "- Error: Required dependency $1 is not installed." >&2; exit 1; } } -function _install_bayesh(){ +_install_bayesh(){ echo "- downloading Bayesh ${version} for architecture ${goarch} to ${target_dir}/bayesh" ${_sudo} curl -sSL "$url" | ${_sudo} tar -xzf - -C "${target_dir}" ${_sudo} chmod +x "${target_dir}/bayesh" - command -v "bayesh" &> /dev/null || { echo "- Error: bayesh could not be found after installation." >&2; exit 1; } + command -v "bayesh" > /dev/null 2>&1 || { echo "- Error: bayesh could not be found after installation." >&2; exit 1; } } -function _print_bayesh() { +_print_bayesh() { CYAN="\033[94m" RESET="\033[0m" - echo -e "${CYAN}" + printf "%b\n" "${CYAN}" echo "░████████ ░██ " echo "░██ ░██ ░██ " echo "░██ ░██ ░██████ ░██ ░██ ░███████ ░███████ ░████████ " @@ -77,7 +76,7 @@ function _print_bayesh() { echo "░█████████ ░█████░██ ░█████░██ ░███████ ░███████ ░██ ░██ " echo " ░██ " echo " ░███████ " - echo -e "${RESET}" + printf "%b\n" "${RESET}" echo "- For documentation, see https://github.com/mads-bisgaard/bayesh" }