github.com/nevalang/neva@v0.23.1-0.20240507185603-7696a9bb8dda/scripts/cn/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          loong64|loongarch64)
    15              arch="loong64"
    16              ;;
    17          *)
    18              echo "不支持的架构: $arch"
    19              exit 1
    20              ;;
    21      esac
    22      echo "${os}-${arch}"
    23  }
    24  
    25  # Determine latest release tag
    26  LATEST_TAG=$(curl -s https://api.github.com/repos/nevalang/neva/releases/latest | grep "tag_name" | cut -d '"' -f 4)
    27  echo "最新版本: $LATEST_TAG"
    28  
    29  # Determine platform
    30  PLATFORM=$(detect_platform)
    31  echo "平台: $PLATFORM"
    32  
    33  # Build the release URL
    34  BIN_NAME="neva"
    35  BIN_URL="https://github.moeyy.xyz/https://github.com/nevalang/neva/releases/download/$LATEST_TAG/${BIN_NAME}-${PLATFORM}"
    36  
    37  # Download the binary
    38  echo "下载中..."
    39  curl -L $BIN_URL -o $BIN_NAME
    40  
    41  # Make the binary executable
    42  chmod +x $BIN_NAME
    43  
    44  # Move the binary to a location in the user's PATH
    45  INSTALL_DIR="/usr/local/bin"
    46  sudo mv $BIN_NAME $INSTALL_DIR
    47  echo "已经将 $BIN_NAME 成功安装到 $INSTALL_DIR"