|
| 1 | +#!/bin/bash |
| 2 | +# This script installs the slick deploy to /usr/local/bin/slick from Github release |
| 3 | +args=("$@") |
| 4 | +custom_version=${args[0]} |
| 5 | + |
| 6 | +# Function to detect latest GitHub release |
| 7 | +get_latest_release() { |
| 8 | + local repo=$1 |
| 9 | + curl -s "https://api.github.com/repos/${repo}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' |
| 10 | +} |
| 11 | + |
| 12 | +if [ -z "$custom_version" ]; then |
| 13 | + custom_version=$(get_latest_release "scmmishra/slick-deploy") |
| 14 | +fi |
| 15 | + |
| 16 | +# Function to detect platform, architecture, etc. |
| 17 | +detect_platform() { |
| 18 | + OS=$(uname -s) |
| 19 | + ARCH=$(uname -m) |
| 20 | + |
| 21 | + case $OS in |
| 22 | + Linux) OS="linux" ;; |
| 23 | + Darwin) OS="darwin" ;; |
| 24 | + *) |
| 25 | + echo "Unsupported operating system: $OS" |
| 26 | + exit 1 |
| 27 | + ;; |
| 28 | + esac |
| 29 | + |
| 30 | + case $ARCH in |
| 31 | + x86_64) ARCH="amd64" ;; |
| 32 | + aarch64 | arm64) ARCH="arm64" ;; |
| 33 | + *) |
| 34 | + echo "Unsupported architecture: $ARCH" |
| 35 | + exit 1 |
| 36 | + ;; |
| 37 | + esac |
| 38 | + |
| 39 | + echo "Detected platform: $OS $ARCH" |
| 40 | +} |
| 41 | + |
| 42 | +# Function to download file from GitHub release |
| 43 | +download_from_github() { |
| 44 | + local repo=$1 |
| 45 | + local release=$2 |
| 46 | + local name=$3 |
| 47 | + local filename=${name}_${release}_${OS}_${ARCH}.tar.gz |
| 48 | + # Construct download URL |
| 49 | + local download_url="https://github.com/${repo}/releases/download/${release}/${filename}" |
| 50 | + |
| 51 | + # Use curl to download the file quietly |
| 52 | + echo "Downloading ${name} ${release} from GitHub release" |
| 53 | + curl -sL -o "${filename}" "${download_url}" |
| 54 | + |
| 55 | + # Determine the binary directory |
| 56 | + local binary_dir="" |
| 57 | + if [ "$OS" == "linux" ] || [ "$OS" == "darwin" ]; then |
| 58 | + binary_dir="/usr/local/bin" |
| 59 | + fi |
| 60 | + echo "Installing ${name}" |
| 61 | + echo filename |
| 62 | + sudo tar -xzvf "${filename}" -C "${binary_dir}" > /dev/null |
| 63 | + |
| 64 | + # Make the binary executable |
| 65 | + sudo chmod +x "${binary_dir}/slick" |
| 66 | + |
| 67 | + # Cleanup |
| 68 | + rm "${filename}" |
| 69 | + |
| 70 | + echo "${name} installed successfully to ${binary_dir}/slick" |
| 71 | +} |
| 72 | + |
| 73 | +echo "⠠⠞⠑⠭⠞⠶⠠⠑⠙⠊⠞⠕⠗ Slick Deploy ⠠⠞⠑⠭⠞⠶⠠⠑⠙⠊⠞⠕⠗" |
| 74 | +detect_platform |
| 75 | +download_from_github "scmmishra/slick-deploy" $custom_version "slick-deploy" |
0 commit comments