|
1 | | -name: Build shared libraries and publish to Maven Central |
| 1 | +name: Build JNI bindings |
2 | 2 | on: |
3 | 3 | workflow_dispatch: |
4 | 4 | release: |
5 | 5 | types: [created] |
6 | 6 | jobs: |
7 | | - build-linux-x86-64: |
8 | | - name: Build Linux x86-64 |
9 | | - runs-on: ubuntu-latest |
| 7 | + build: |
| 8 | + name: Build ${{ matrix.target.name }}-${{ matrix.target.arch }} |
| 9 | + runs-on: ${{ matrix.target.image }} |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + target: |
| 14 | + - { |
| 15 | + name: Linux, |
| 16 | + arch: x86_64, |
| 17 | + image: ubuntu-latest, |
| 18 | + cmake: "-DCMAKE_CXX_FLAGS='-march=x86-64'" |
| 19 | + } |
| 20 | + # - { |
| 21 | + # name: Linux, |
| 22 | + # arch: aarch64, |
| 23 | + # image: ubuntu-latest, |
| 24 | + # cmake: "-DCMAKE_CXX_FLAGS='-march=armv8-a'" |
| 25 | + # } |
| 26 | + - { |
| 27 | + name: Mac, |
| 28 | + arch: x86_64, |
| 29 | + image: macos-latest, |
| 30 | + cmake: "-DCMAKE_OSX_ARCHITECTURES=x86_64" |
| 31 | + } |
| 32 | + - { |
| 33 | + name: Mac, |
| 34 | + arch: aarch64, |
| 35 | + image: macos-latest, |
| 36 | + cmake: "-DCMAKE_OSX_ARCHITECTURES=arm64" |
| 37 | + } |
| 38 | + - { |
| 39 | + name: Windows, |
| 40 | + arch: x86_64, |
| 41 | + image: windows-latest, |
| 42 | + cmake: "-DCMAKE_GENERATOR_PLATFORM=x64" |
| 43 | + } |
| 44 | + # - { |
| 45 | + # name: Windows, |
| 46 | + # arch: aarch64, |
| 47 | + # image: windows-latest, |
| 48 | + # cmake: "-DCMAKE_GENERATOR_PLATFORM=ARM64" |
| 49 | + # } |
10 | 50 | steps: |
11 | | - - name: Checkout llama.cpp |
| 51 | + - name: Checkout Repository |
12 | 52 | uses: actions/checkout@v4 |
13 | 53 | with: |
14 | | - repository: ggerganov/llama.cpp |
15 | | - - name: CMake |
| 54 | + submodules: recursive |
| 55 | + ref: "jni" |
| 56 | + - name: CMake (Windows) |
| 57 | + if: ${{ matrix.target.name == 'Windows' }} |
| 58 | + shell: cmd |
| 59 | + run: | |
| 60 | + cd scripts && .\build.bat ${{ matrix.target.cmake }} -DOS_NAME=${{ matrix.target.name }} -DOS_ARCH=${{ matrix.target.arch }} |
| 61 | + - name: CMake (Unix) |
| 62 | + if: ${{ matrix.target.name != 'Windows' }} |
16 | 63 | shell: bash |
17 | 64 | run: | |
18 | | - mkdir -p build && cd build |
19 | | - cmake .. -DBUILD_SHARED_LIBS=ON -DLLAMA_BUILD_TESTS=OFF || exit 1 |
20 | | - cmake --build . --config Release || exit 1 |
21 | | - - name: Upload linux-x86-64 |
| 65 | + cd scripts && ./build.sh ${{ matrix.target.cmake }} -DOS_NAME=${{ matrix.target.name }} -DOS_ARCH=${{ matrix.target.arch }} |
| 66 | + - name: Upload Unix Artifact |
| 67 | + if: ${{ matrix.target.name == 'Windows' }} |
| 68 | + uses: actions/upload-artifact@v3 |
| 69 | + with: |
| 70 | + name: artifacts |
| 71 | + path: ${{ github.workspace }}\src\main\resources\de\kherud\llama\ |
| 72 | + - name: Upload Windows Artifact |
| 73 | + if: ${{ matrix.target.name != 'Windows' }} |
22 | 74 | uses: actions/upload-artifact@v3 |
23 | 75 | with: |
24 | | - name: linux-x86-64 |
25 | | - path: build/libllama.so |
26 | | -# build-linux-arm64: |
27 | | -# name: Build Linux arm64 |
28 | | -# runs-on: ubuntu-latest |
29 | | -# container: |
30 | | -# image: arm64v8/ubuntu:latest |
31 | | -# options: --platform linux/arm64 |
32 | | -# steps: |
33 | | -# - name: Install dependencies |
34 | | -# run: | |
35 | | -# apt-get update |
36 | | -# apt-get install -y build-essential cmake |
37 | | -# - name: Checkout llama.cpp |
38 | | -# uses: actions/checkout@v4 |
39 | | -# with: |
40 | | -# repository: ggerganov/llama.cpp |
41 | | -# - name: CMake |
42 | | -# shell: bash |
43 | | -# run: | |
44 | | -# mkdir -p build && cd build |
45 | | -# cmake .. -DBUILD_SHARED_LIBS=ON -DLLAMA_BUILD_TESTS=OFF || exit 1 |
46 | | -# cmake --build . --config Release || exit 1 |
47 | | -# - name: Upload linux-arm64 |
48 | | -# uses: actions/upload-artifact@v3 |
49 | | -# with: |
50 | | -# name: linux-arm64 |
51 | | -# path: build/libllama.so |
52 | | - |
53 | | - |
| 76 | + name: artifacts |
| 77 | + path: ${{ github.workspace }}/src/main/resources/de/kherud/llama/ |
54 | 78 | publish: |
55 | | - needs: [build-linux-x86-64] |
| 79 | + needs: [build] |
56 | 80 | runs-on: ubuntu-latest |
57 | 81 | steps: |
58 | | - - name: Checkout java-llama.cpp |
| 82 | + - name: Checkout Repository |
59 | 83 | uses: actions/checkout@v4 |
60 | | - - name: Download libraries |
| 84 | + with: |
| 85 | + ref: "jni" |
| 86 | + - name: Download Artifacts |
61 | 87 | uses: actions/download-artifact@v3 |
62 | | - with: # specifying no name downloads all artifacts to a directory of their name |
63 | | - path: src/main/resources |
| 88 | + with: |
| 89 | + name: artifacts |
| 90 | + path: ${{ github.workspace }}/src/main/resources/de/kherud/llama/ |
64 | 91 | - name: Set up Maven Central Repository |
65 | 92 | uses: actions/setup-java@v3 |
66 | 93 | with: |
|
0 commit comments