tiny-refactor(workflow): refine conditions for Linux dependency insta… #132
This file contains hidden or 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
| name: build, test and release sqlite-ai | |
| on: | |
| push: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'isim' && matrix.name != 'ios' && ' + test' || ''}} | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux builds | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-cpu | |
| make: LLAMA="-DGGML_NATIVE=ON" | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-cpu-avx2 | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON" | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-cpu-avx512 | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX512_VNNI=ON" | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-openblas | |
| make: LLAMA="-DGGML_NATIVE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-vulkan | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_VULKAN=ON" | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux-opencl | |
| make: LLAMA="-DGGML_NATIVE=ON -DGGML_OPENCL=ON" | |
| # Linux ARM64 builds | |
| - os: LinuxARM64 | |
| arch: arm64 | |
| name: linux-cpu | |
| make: LLAMA="-DGGML_NATIVE=ON" | |
| - os: LinuxARM64 | |
| arch: arm64 | |
| name: linux-neon | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=armv8.2-a" | |
| - os: LinuxARM64 | |
| arch: arm64 | |
| name: linux-openblas | |
| make: LLAMA="-DGGML_NATIVE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" | |
| - os: LinuxARM64 | |
| arch: arm64 | |
| name: linux-vulkan | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_VULKAN=ON" | |
| - os: LinuxARM64 | |
| arch: arm64 | |
| name: linux-opencl | |
| make: LLAMA="-DGGML_NATIVE=ON -DGGML_OPENCL=ON" | |
| # macOS builds | |
| - os: macos-latest | |
| name: macos | |
| make: LLAMA="-DGGML_NATIVE=ON -DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple" WHISPER="-DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple -DWHISPER_COREML=ON -DWHISPER_COREML_ALLOW_FALLBACK=ON" | |
| # Windows builds (commented out but ready to enable) | |
| - os: windows-latest | |
| arch: x86_64 | |
| name: windows-cpu | |
| make: LLAMA="-DGGML_NATIVE=ON" | |
| - os: windows-latest | |
| arch: x86_64 | |
| name: windows-vulkan | |
| make: LLAMA="-DGGML_NATIVE=OFF -DGGML_VULKAN=ON" | |
| # Android builds | |
| - os: ubuntu-latest | |
| arch: arm64-v8a | |
| name: android | |
| make: PLATFORM=android ARCH=arm64-v8a | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: android | |
| make: PLATFORM=android ARCH=x86_64 | |
| sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip | |
| # iOS builds | |
| - os: macos-latest | |
| name: ios | |
| make: PLATFORM=ios | |
| - os: macos-latest | |
| name: isim | |
| make: PLATFORM=isim | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| with: | |
| submodules: true | |
| - uses: msys2/setup-msys2@v2.27.0 | |
| if: matrix.os == 'windows-latest' | |
| with: | |
| msystem: mingw64 | |
| install: >- | |
| mingw-w64-x86_64-cc | |
| mingw-w64-x86_64-cmake | |
| make | |
| - name: linux install openblas | |
| if: matrix.name == 'linux-openblas' | |
| run: | | |
| sudo apt-get install -y libopenblas-dev | |
| - name: linux install opencl | |
| if: matrix.name == 'linux-opencl' | |
| run: | | |
| sudo apt-get install -y opencl-headers ocl-icd-opencl-dev | |
| - name: linux install vulkan (x86_64) | |
| if: matrix.name == 'linux-vulkan' && matrix.arch == 'x86_64' | |
| run: | | |
| wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - | |
| sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list | |
| sudo apt-get update -y | |
| sudo apt-get install -y mesa-vulkan-drivers | |
| # Vulkan is no longer packed for Ubuntu | |
| wget https://sdk.lunarg.com/sdk/download/latest/linux/vulkan-sdk.tar.xz?Human=true -O vulkan-sdk.tar.xz | |
| tar -xf vulkan-sdk.tar.xz | |
| cd $(ls -d 1.* | head -n1) | |
| source setup-env.sh | |
| echo "VULKAN_SDK=$VULKAN_SDK" >> $GITHUB_ENV | |
| echo "PATH=$PATH" >> $GITHUB_ENV | |
| echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
| echo "VK_ADD_LAYER_PATH=$VK_ADD_LAYER_PATH" >> $GITHUB_ENV | |
| - name: linux install vulkan (arm64) | |
| if: matrix.name == 'linux-vulkan' && matrix.arch == 'arm64' | |
| run: | | |
| sudo dpkg --add-architecture arm64 | |
| # Add arch-specific repositories for non-amd64 architectures | |
| cat << EOF | sudo tee /etc/apt/sources.list.d/arm64-ports.list | |
| deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble main universe | |
| deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main universe | |
| deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-security main universe | |
| deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main universe | |
| EOF | |
| sudo apt-get update || true ;# Prevent failure due to missing URLs. | |
| sudo apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| glslc \ | |
| crossbuild-essential-arm64 \ | |
| libvulkan-dev:arm64 | |
| - name: windows build modules | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| make build/llama.cpp.stamp ${{ matrix.make && matrix.make || ''}} | |
| make build/whisper.cpp.stamp ${{ matrix.make && matrix.make || ''}} | |
| make build/miniaudio.stamp ${{ matrix.make && matrix.make || ''}} | |
| shell: msys2 {0} | |
| - name: build sqlite-ai | |
| run: make extension ${{ matrix.make && matrix.make || ''}} | |
| - name: windows install sqlite3 | |
| if: matrix.os == 'windows-latest' | |
| run: choco install sqlite -y | |
| - name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION | |
| if: matrix.name == 'macos' | |
| run: brew link sqlite --force | |
| - name: android setup test environment | |
| if: matrix.name == 'android' && matrix.arch != 'arm64-v8a' | |
| run: | | |
| echo "::group::enable kvm group perms" | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| echo "::endgroup::" | |
| echo "::group::download and build sqlite3 without SQLITE_OMIT_LOAD_EXTENSION" | |
| curl -O ${{ matrix.sqlite-amalgamation-zip }} | |
| unzip sqlite-amalgamation-*.zip | |
| export ${{ matrix.make }} | |
| $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.arch }}-linux-android26-clang sqlite-amalgamation-*/shell.c sqlite-amalgamation-*/sqlite3.c -o sqlite3 -ldl | |
| # remove unused folders to save up space | |
| rm -rf sqlite-amalgamation-*.zip sqlite-amalgamation-* | |
| echo "::endgroup::" | |
| echo "::group::prepare the test script" | |
| make test PLATFORM=$PLATFORM ARCH=$ARCH || echo "It should fail. Running remaining commands in the emulator" | |
| cat > commands.sh << EOF | |
| mv -f /data/local/tmp/sqlite3 /system/xbin | |
| cd /data/local/tmp | |
| $(make test PLATFORM=$PLATFORM ARCH=$ARCH -n) | |
| EOF | |
| # remove big unused folders to avoid emulator errors | |
| rm -rf build modules | |
| echo "::endgroup::" | |
| - name: android test sqlite-ai | |
| if: matrix.name == 'android' && matrix.arch != 'arm64-v8a' | |
| uses: reactivecircus/android-emulator-runner@v2.34.0 | |
| with: | |
| api-level: 26 | |
| arch: ${{ matrix.arch }} | |
| script: | | |
| adb root | |
| adb remount | |
| adb push ${{ github.workspace }}/. /data/local/tmp/ | |
| adb shell "sh /data/local/tmp/commands.sh" | |
| - name: test sqlite-ai | |
| if: startsWith(matrix.name, 'linux-') || startsWith(matrix.name, 'windows-') || matrix.name == 'macos' | |
| run: make test | |
| - uses: actions/upload-artifact@v4.6.2 | |
| if: always() | |
| with: | |
| name: ai-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} | |
| path: dist/ai.* | |
| if-no-files-found: error | |
| release: | |
| runs-on: ubuntu-latest | |
| name: release | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4.2.2 | |
| - uses: actions/download-artifact@v4.2.1 | |
| with: | |
| path: artifacts | |
| - name: release tag version from sqlite-ai.h | |
| id: tag | |
| run: | | |
| VERSION=$(make version) | |
| if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| LATEST=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name') | |
| if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "::warning file=src/sqlite-ai.h::To release a new version, please update the SQLITE_AI_VERSION in src/sqlite-ai.h to be different than the latest $LATEST" | |
| fi | |
| exit 0 | |
| fi | |
| echo "❌ SQLITE_AI_VERSION not found in sqlite-ai.h" | |
| exit 1 | |
| - name: zip artifacts | |
| run: | | |
| for folder in "artifacts"/*; do | |
| if [ -d "$folder" ]; then | |
| name=$(basename "$folder") | |
| zip -jq "${name}-${{ steps.tag.outputs.version }}.zip" "$folder"/* | |
| tar -cJf "${name}-${{ steps.tag.outputs.version }}.tar.xz" -C "$folder" . | |
| tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" . | |
| fi | |
| done | |
| - uses: softprops/action-gh-release@v2.2.1 | |
| if: steps.tag.outputs.version != '' | |
| with: | |
| generate_release_notes: true | |
| tag_name: ${{ steps.tag.outputs.version }} | |
| files: | | |
| ai-*-${{ steps.tag.outputs.version }}.zip | |
| ai-*-${{ steps.tag.outputs.version }}.tar.xz | |
| ai-*-${{ steps.tag.outputs.version }}.tar.gz | |
| make_latest: true |