forked from yetone/avante.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(crates): prebuilt binaries (yetone#473)
* feat(crates): prebuilt binaries Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * chore: update name Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * chore: build on PR Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * chore: only build for lua51 and luajit Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * feat: build stuff Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * chore: only build if changes in Rust Signed-off-by: Aaron Pham <contact@aarnphm.xyz> * fix: remove deadcode Signed-off-by: Aaron Pham <contact@aarnphm.xyz> --------- Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
- Loading branch information
Showing
8 changed files
with
223 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Nightly Build | ||
|
||
on: | ||
schedule: | ||
- cron: '0 2 * * *' # Runs at 2 AM UTC every day | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'crates/**' | ||
- '**/Cargo.toml' | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
feature: [lua51, luajit] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: 1.80.0 | ||
- name: Build all crates | ||
run: cargo build --release --features ${{ matrix.feature }} | ||
- name: handle binaries | ||
shell: bash | ||
run: | | ||
mkdir -p results | ||
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | ||
OS="linux" | ||
EXT="so" | ||
elif [ "${{ matrix.os }}" == "macos-latest" ]; then | ||
OS="macOS" | ||
EXT="dylib" | ||
else | ||
OS="windows" | ||
EXT="dll" | ||
fi | ||
if [ "${{ matrix.os }}" == "windows-latest" ]; then | ||
cp target/release/avante_templates.$EXT results/avante_templates.$EXT | ||
cp target/release/avante_tokenizers.$EXT results/avante_tokenizers.$EXT | ||
else | ||
cp target/release/libavante_templates.$EXT results/avante_templates.$EXT | ||
cp target/release/libavante_tokenizers.$EXT results/avante_tokenizers.$EXT | ||
fi | ||
- name: Upload binaries | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: avante_lib-${{ matrix.os }}-${{ matrix.feature }} | ||
path: results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
function avante#build() abort | ||
return join(luaeval("require('avante').build()"), "\n") | ||
function avante#build(...) abort | ||
let l:source = get(a:, 1, v:false) | ||
return join(luaeval("require('avante').build(_A)", l:source), "\n") | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
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 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) | ||
|
||
# Get the artifact download URL based on the platform and Lua version | ||
case "$(uname -s)" in | ||
Linux*) | ||
PLATFORM="linux" | ||
;; | ||
Darwin*) | ||
PLATFORM="macos" | ||
;; | ||
CYGWIN* | MINGW* | MSYS*) | ||
PLATFORM="windows" | ||
;; | ||
*) | ||
echo "Unsupported platform" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Set the Lua version (lua54 or luajit) | ||
LUA_VERSION="${LUA_VERSION:-luajit}" | ||
|
||
# Set the artifact name pattern | ||
ARTIFACT_NAME_PATTERN="avante_lib-$PLATFORM-latest-$LUA_VERSION" | ||
|
||
# Get the artifact download URL | ||
ARTIFACT_URL=$(curl -s -H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts" | | ||
\grep -oP "(?<=\"archive_download_url\": \")https://[^\"]+/$ARTIFACT_NAME_PATTERN[^\"]+") | ||
|
||
mkdir -p "$TARGET_DIR" | ||
curl -L "$ARTIFACT_URL" | tar -xz -C "$TARGET_DIR" --strip-components=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters