2024-09-15 10:53:23 -04:00
|
|
|
#!/usr/bin/env bash
|
2024-09-03 06:20:53 -04:00
|
|
|
|
2024-09-26 11:47:54 +08:00
|
|
|
set -e
|
|
|
|
|
2024-09-03 06:20:53 -04:00
|
|
|
REPO_OWNER="yetone"
|
|
|
|
REPO_NAME="avante.nvim"
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|
|
|
|
|
|
|
# Set the target directory to clone the artifact
|
|
|
|
TARGET_DIR="${SCRIPT_DIR}/build"
|
|
|
|
|
|
|
|
# Get the artifact download URL based on the platform and Lua version
|
|
|
|
case "$(uname -s)" in
|
|
|
|
Linux*)
|
2024-09-26 11:36:54 +08:00
|
|
|
PLATFORM="linux"
|
2024-09-03 06:20:53 -04:00
|
|
|
;;
|
|
|
|
Darwin*)
|
2024-09-26 11:36:54 +08:00
|
|
|
PLATFORM="darwin"
|
2024-09-03 06:20:53 -04:00
|
|
|
;;
|
|
|
|
CYGWIN* | MINGW* | MSYS*)
|
|
|
|
PLATFORM="windows"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported platform"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-09-26 11:36:54 +08:00
|
|
|
# Get the architecture (x86_64 or aarch64)
|
|
|
|
case "$(uname -m)" in
|
|
|
|
x86_64)
|
|
|
|
ARCH="x86_64"
|
|
|
|
;;
|
|
|
|
aarch64)
|
|
|
|
ARCH="aarch64"
|
|
|
|
;;
|
|
|
|
arm64)
|
|
|
|
ARCH="aarch64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported architecture"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-09-03 06:20:53 -04:00
|
|
|
# Set the Lua version (lua54 or luajit)
|
|
|
|
LUA_VERSION="${LUA_VERSION:-luajit}"
|
|
|
|
|
|
|
|
# Set the artifact name pattern
|
2024-09-26 11:36:54 +08:00
|
|
|
ARTIFACT_NAME_PATTERN="avante_lib-$PLATFORM-$ARCH-$LUA_VERSION"
|
2024-09-03 06:20:53 -04:00
|
|
|
|
2025-01-01 20:51:52 +08:00
|
|
|
test_command() {
|
|
|
|
command -v "$1" >/dev/null 2>&1
|
|
|
|
}
|
2024-09-03 06:20:53 -04:00
|
|
|
|
2025-01-01 20:51:52 +08:00
|
|
|
test_gh_auth() {
|
|
|
|
if gh api user >/dev/null 2>&1; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
2024-09-26 11:47:54 +08:00
|
|
|
|
2025-01-01 20:51:52 +08:00
|
|
|
if [ ! -d "$TARGET_DIR" ]; then
|
|
|
|
mkdir -p "$TARGET_DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test_command "gh" && test_gh_auth; then
|
2025-01-19 01:54:24 +01:00
|
|
|
gh release download --repo "github.com/$REPO_OWNER/$REPO_NAME" --pattern "*$ARTIFACT_NAME_PATTERN*" --clobber --output - | tar -zxv -C "$TARGET_DIR"
|
2025-01-01 20:51:52 +08:00
|
|
|
else
|
|
|
|
# Get the artifact download URL
|
|
|
|
ARTIFACT_URL=$(curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest" | grep "browser_download_url" | cut -d '"' -f 4 | grep $ARTIFACT_NAME_PATTERN)
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
mkdir -p "$TARGET_DIR"
|
|
|
|
|
|
|
|
curl -L "$ARTIFACT_URL" | tar -zxv -C "$TARGET_DIR"
|
|
|
|
fi
|
2024-09-03 06:53:14 -04:00
|
|
|
|