Skip to content

Commit

Permalink
fix(release): supports darwin x86_64 (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Sep 26, 2024
1 parent 22243bc commit 67adc26
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 18 deletions.
51 changes: 36 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,59 @@ jobs:
releases-matrix:
needs: [create-release]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
feature: [lua51, luajit]
runs-on: ${{ matrix.os }}
config:
- os: ubuntu-latest
os_name: linux
arch: x86_64
rust_target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
os_name: linux
arch: aarch64
rust_target: aarch64-unknown-linux-gnu
- os: macos-13
os_name: darwin
arch: x86_64
rust_target: x86_64-apple-darwin
- os: macos-latest
os_name: darwin
arch: aarch64
rust_target: aarch64-apple-darwin
- os: windows-latest
os_name: windows
arch: x86_64
rust_target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
targets: ${{ matrix.config.rust_target }}
toolchain: 1.80.0
- name: Build all crates
run: cargo build --release --features ${{ matrix.feature }}
- name: Handle binaries
if: ${{ matrix.os != 'windows-latest' }}
if: ${{ matrix.config.os_name != 'windows' }}
shell: bash
run: |
mkdir -p results
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
OS="linux"
if [ "${{ matrix.config.os_name }}" == "linux" ]; then
EXT="so"
else
OS="macOS"
EXT="dylib"
fi
cp target/release/libavante_templates.$EXT results/avante_templates.$EXT
cp target/release/libavante_tokenizers.$EXT results/avante_tokenizers.$EXT
cp target/release/libavante_repo_map.$EXT results/avante_repo_map.$EXT
cd results
tar zcvf avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz *.${EXT}
tar zcvf avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.tar.gz *.${EXT}
- name: Handle binaries (Windows)
if: ${{ matrix.os == 'windows-latest' }}
if: ${{ matrix.config.os_name == 'windows' }}
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path results
Expand All @@ -91,26 +112,26 @@ jobs:
Set-Location -Path results
$dllFiles = Get-ChildItem -Filter "*.dll" | Select-Object -ExpandProperty Name
Compress-Archive -Path $dllFiles -DestinationPath "avante_lib-${{ matrix.os }}-${{ matrix.feature }}.zip"
Compress-Archive -Path $dllFiles -DestinationPath "avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.zip"
- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
if: ${{ matrix.os != 'windows-latest' }}
if: ${{ matrix.config.os_name != 'windows' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_NAME: avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz
ASSET_NAME: avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.tar.gz
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: ./results/avante_lib-${{ matrix.os }}-${{ matrix.feature }}.tar.gz
asset_path: ./results/avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.tar.gz
- name: Upload Release Asset (Windows)
uses: shogo82148/actions-upload-release-asset@v1
if: ${{ matrix.os == 'windows-latest' }}
if: ${{ matrix.config.os_name == 'windows' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET_NAME: avante_lib-${{ matrix.os }}-${{ matrix.feature }}.zip
ASSET_NAME: avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.zip
with:
upload_url: ${{ needs.create-release.outputs.release_upload_url }}
asset_path: ./results/avante_lib-${{ matrix.os }}-${{ matrix.feature }}.zip
asset_path: ./results/avante_lib-${{ matrix.config.os_name }}-${{ matrix.config.arch }}-${{ matrix.feature }}.zip

publish-release:
permissions:
Expand Down
23 changes: 20 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ TARGET_DIR="${SCRIPT_DIR}/build"
# Get the artifact download URL based on the platform and Lua version
case "$(uname -s)" in
Linux*)
PLATFORM="ubuntu"
PLATFORM="linux"
;;
Darwin*)
PLATFORM="macos"
PLATFORM="darwin"
;;
CYGWIN* | MINGW* | MSYS*)
PLATFORM="windows"
Expand All @@ -25,11 +25,28 @@ CYGWIN* | MINGW* | MSYS*)
;;
esac

# 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

# 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"
ARTIFACT_NAME_PATTERN="avante_lib-$PLATFORM-$ARCH-$LUA_VERSION"

# Get the artifact 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)
Expand Down

0 comments on commit 67adc26

Please sign in to comment.