github.com/nevalang/neva@v0.23.1-0.20240507185603-7696a9bb8dda/scripts/install.sh (about) 1 #!/bin/bash 2 3 # Function to detect platform and architecture 4 detect_platform() { 5 local os=$(uname -s | tr '[:upper:]' '[:lower:]') 6 local arch=$(uname -m) 7 case $arch in 8 x86_64) 9 arch="amd64" 10 ;; 11 arm64|aarch64) 12 arch="arm64" 13 ;; 14 *) 15 echo "Unsupported architecture: $arch" 16 exit 1 17 ;; 18 esac 19 echo "${os}-${arch}" 20 } 21 22 # Determine latest release tag 23 LATEST_TAG=$(curl -s https://api.github.com/repos/nevalang/neva/releases/latest | grep "tag_name" | cut -d '"' -f 4) 24 echo "Latest tag is $LATEST_TAG" 25 26 # Determine platform 27 PLATFORM=$(detect_platform) 28 echo "Platform is $PLATFORM" 29 30 # Build the release URL 31 BIN_NAME="neva" 32 BIN_URL="https://github.com/nevalang/neva/releases/download/$LATEST_TAG/${BIN_NAME}-${PLATFORM}" 33 34 # Download the binary 35 echo "Downloading..." 36 curl -L $BIN_URL -o $BIN_NAME 37 38 # Make the binary executable 39 chmod +x $BIN_NAME 40 41 # Move the binary to a location in the user's PATH 42 INSTALL_DIR="/usr/local/bin" 43 sudo mv $BIN_NAME $INSTALL_DIR 44 echo "$BIN_NAME installed successfully to $INSTALL_DIR"