|
| 1 | +name: "Build llama-lfm2-audio (Native)" |
| 2 | +description: "Builds llama-lfm2-audio natively and uploads artifacts" |
| 3 | + |
| 4 | +inputs: |
| 5 | + platform: |
| 6 | + description: "Platform identifier (e.g., ubuntu-x64, macos-arm64, android-arm64)" |
| 7 | + required: true |
| 8 | + setup_ndk: |
| 9 | + description: "Whether to setup Android NDK" |
| 10 | + required: false |
| 11 | + default: "false" |
| 12 | + ndk_version: |
| 13 | + description: "Android NDK version to install" |
| 14 | + required: false |
| 15 | + default: "29.0.14206865" |
| 16 | + |
| 17 | +runs: |
| 18 | + using: "composite" |
| 19 | + steps: |
| 20 | + - name: Setup Java for Android |
| 21 | + if: inputs.setup_ndk == 'true' |
| 22 | + uses: actions/setup-java@v3 |
| 23 | + with: |
| 24 | + java-version: "17" |
| 25 | + distribution: "temurin" |
| 26 | + |
| 27 | + - name: Setup Android SDK |
| 28 | + if: inputs.setup_ndk == 'true' |
| 29 | + uses: android-actions/setup-android@v3 |
| 30 | + |
| 31 | + - name: Install Android NDK |
| 32 | + if: inputs.setup_ndk == 'true' |
| 33 | + shell: bash |
| 34 | + run: | |
| 35 | + sdkmanager "ndk;${{ inputs.ndk_version }}" |
| 36 | + NDK_PATH="${ANDROID_HOME}/ndk/${{ inputs.ndk_version }}" |
| 37 | + echo "ANDROID_NDK_ROOT=${NDK_PATH}" >> $GITHUB_ENV |
| 38 | + echo "Android NDK installed at: ${NDK_PATH}" |
| 39 | + ls -la "${NDK_PATH}/build/cmake/" || echo "Toolchain path not found" |
| 40 | +
|
| 41 | + - name: Configure and build llama-lfm2-audio |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + cp .github/cmake/llama-lfm2-audio-presets.json ./CMakeUserPresets.json |
| 45 | +
|
| 46 | + rm -rf build-${{ inputs.platform }} |
| 47 | + cmake --preset lfm2-audio-${{ inputs.platform }} |
| 48 | + cmake --build build-${{ inputs.platform }} --config Release --target llama-lfm2-audio -j $(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4) |
| 49 | + cmake --build build-${{ inputs.platform }} --config Release --target llama-mtmd-cli -j $(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4) |
| 50 | +
|
| 51 | + - name: Strip debug symbols |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + # Note: Linker flags (--strip-all) work on Linux but not on macOS. |
| 55 | + # Using the strip command to minimize divergence between platforms. |
| 56 | + cd build-${{ inputs.platform }}/bin |
| 57 | +
|
| 58 | + if [[ "${{ inputs.platform }}" == "macos-arm64" ]]; then |
| 59 | + strip llama-lfm2-audio llama-mtmd-cli |
| 60 | + find . -type f -name "*.dylib" -exec strip {} \; |
| 61 | + elif [[ "${{ inputs.platform }}" == "android-arm64" ]]; then |
| 62 | + ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-all llama-lfm2-audio llama-mtmd-cli |
| 63 | + find . -type f -name "*.so" -exec ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-all {} \; |
| 64 | + else |
| 65 | + # Linux |
| 66 | + strip --strip-all llama-lfm2-audio llama-mtmd-cli |
| 67 | + find . -type f -name "*.so" -exec strip --strip-all {} \; |
| 68 | + fi |
| 69 | +
|
| 70 | + - name: Create release package |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + mkdir -p artifacts |
| 74 | + cd build-${{ inputs.platform }} |
| 75 | + cp ../LICENSE bin |
| 76 | + mv bin lfm2-audio-${{ inputs.platform }} |
| 77 | + mv lfm2-audio-${{ inputs.platform }} ../artifacts/ |
| 78 | +
|
| 79 | + - name: Upload to GitHub Artifacts |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: lfm2-audio-${{ inputs.platform }} |
| 83 | + path: artifacts/ |
0 commit comments