Skip to content

Commit

Permalink
fix(ci): pre built tar.gz (yetone#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Sep 3, 2024
1 parent 0c14792 commit 90c5f72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ jobs:
fi
cd results
tar cvf avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar *.${EXT}
tar zcvf avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz *.${EXT}
- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_NAME: avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar
ASSET_NAME: avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: ./results/avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar
asset_path: ./results/avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz

publish-release:
permissions:
Expand Down
28 changes: 3 additions & 25 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#!/bin/bash

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
set -xeo pipefail

REPO_OWNER="yetone"
REPO_NAME="avante.nvim"
Expand All @@ -22,12 +10,6 @@ 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 latest successful run ID of the workflow
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
Linux*)
Expand All @@ -52,12 +34,8 @@ 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" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts" |
jq -r '.artifacts[] | select(.name | test("'"$ARTIFACT_NAME_PATTERN"'")) | .archive_download_url')
ARTIFACT_URL=$(curl -s "https://api.github.com/repos/yetone/avante.nvim/releases/latest" | grep "browser_download_url" | cut -d '"' -f 4 | grep $ARTIFACT_NAME_PATTERN)

mkdir -p "$TARGET_DIR"

curl -L -H "Authorization: Bearer $GITHUB_TOKEN" "$ARTIFACT_URL" | tar -x -C "$TARGET_DIR"
curl -L "$ARTIFACT_URL" | tar -zxv -C "$TARGET_DIR"

0 comments on commit 90c5f72

Please sign in to comment.