fix(install): prebuilt instruction (closes #474) (#476)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-09-03 06:53:14 -04:00
committed by GitHub
parent a5726bd2bf
commit 24b66e08dc
4 changed files with 31 additions and 13 deletions

View File

@@ -2,6 +2,18 @@
set -eo pipefail
# Check if jq is installed
if ! command -v jq &>/dev/null; then
echo "Error: jq is not installed. Please install jq."
exit 1
fi
# Check if GITHUB_TOKEN is set
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: GITHUB_TOKEN is not set. Please provide a valid GitHub token."
exit 1
fi
REPO_OWNER="yetone"
REPO_NAME="avante.nvim"
@@ -11,9 +23,10 @@ SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
TARGET_DIR="${SCRIPT_DIR}/build"
# Get the latest successful run ID of the workflow
RUN_ID=$(curl -s -H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/build.yaml/runs?status=success&branch=main" |
\grep -oP '(?<="id": )\d+' | head -1)
RUN_ID=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/build.yaml/runs?status=success&branch=main&per_page=1" | jq ".workflow_runs[0].id")
# Get the artifact download URL based on the platform and Lua version
case "$(uname -s)" in
@@ -39,9 +52,12 @@ LUA_VERSION="${LUA_VERSION:-luajit}"
ARTIFACT_NAME_PATTERN="avante_lib-$PLATFORM-latest-$LUA_VERSION"
# Get the artifact download URL
ARTIFACT_URL=$(curl -s -H "Accept: application/vnd.github+json" \
ARTIFACT_URL=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts" |
\grep -oP "(?<=\"archive_download_url\": \")https://[^\"]+/$ARTIFACT_NAME_PATTERN[^\"]+")
jq -r '.artifacts[] | select(.name | test("'"$ARTIFACT_NAME_PATTERN"'")) | .archive_download_url')
mkdir -p "$TARGET_DIR"
curl -L "$ARTIFACT_URL" | tar -xz -C "$TARGET_DIR" --strip-components=1
curl -L -H "Authorization: Bearer $GITHUB_TOKEN" "$ARTIFACT_URL" | tar -x -C "$TARGET_DIR"