Fangjun Kuang
Committed by GitHub

Provide prebuilt .jar files for different java versions. (#1307)

@@ -20,12 +20,18 @@ jobs: @@ -20,12 +20,18 @@ jobs:
20 fail-fast: false 20 fail-fast: false
21 matrix: 21 matrix:
22 os: [ubuntu-latest] 22 os: [ubuntu-latest]
  23 + java-version: ['8', '11', '16', '17', '21']
23 24
24 steps: 25 steps:
25 - uses: actions/checkout@v4 26 - uses: actions/checkout@v4
26 with: 27 with:
27 fetch-depth: 0 28 fetch-depth: 0
28 29
  30 + - uses: actions/setup-java@v4
  31 + with:
  32 + distribution: 'temurin' # See 'Supported distributions' for available options
  33 + java-version: ${{ matrix.java-version }}
  34 +
29 - name: Display PWD 35 - name: Display PWD
30 shell: bash 36 shell: bash
31 run: | 37 run: |
@@ -33,7 +39,8 @@ jobs: @@ -33,7 +39,8 @@ jobs:
33 ls -lh 39 ls -lh
34 du -h -d1 . 40 du -h -d1 .
35 41
36 - - name: Build jar 42 + - name: Build jar ${{ matrix.java-version }}
  43 + if: matrix.java-version == '21'
37 shell: bash 44 shell: bash
38 run: | 45 run: |
39 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 46 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
@@ -44,9 +51,20 @@ jobs: @@ -44,9 +51,20 @@ jobs:
44 cd ../.. 51 cd ../..
45 ls -lh *.jar 52 ls -lh *.jar
46 53
  54 + - name: Build jar ${{ matrix.java-version }}
  55 + shell: bash
  56 + run: |
  57 + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  58 + cd sherpa-onnx/java-api
  59 + make
  60 + ls -lh build/
  61 + cp build/sherpa-onnx.jar ../../sherpa-onnx-$SHERPA_ONNX_VERSION-java${{ matrix.java-version }}.jar
  62 + cd ../..
  63 + ls -lh *.jar
  64 +
47 - uses: actions/upload-artifact@v4 65 - uses: actions/upload-artifact@v4
48 with: 66 with:
49 - name: release-jni-linux-jar 67 + name: release-jni-linux-jar-${{ matrix.java-version }}
50 path: ./*.jar 68 path: ./*.jar
51 69
52 - name: Release jar 70 - name: Release jar
@@ -56,8 +74,12 @@ jobs: @@ -56,8 +74,12 @@ jobs:
56 file_glob: true 74 file_glob: true
57 overwrite: true 75 overwrite: true
58 file: ./*.jar 76 file: ./*.jar
  77 + # repo_name: k2-fsa/sherpa-onnx
  78 + # repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
  79 + # tag: v1.10.23
59 80
60 - name: Build sherpa-onnx 81 - name: Build sherpa-onnx
  82 + if: matrix.java-version == '21'
61 uses: addnab/docker-run-action@v3 83 uses: addnab/docker-run-action@v3
62 with: 84 with:
63 image: quay.io/pypa/manylinux2014_x86_64 85 image: quay.io/pypa/manylinux2014_x86_64
@@ -122,6 +144,7 @@ jobs: @@ -122,6 +144,7 @@ jobs:
122 ls -lh install/bin 144 ls -lh install/bin
123 145
124 - name: Display dependencies of sherpa-onnx for linux 146 - name: Display dependencies of sherpa-onnx for linux
  147 + if: matrix.java-version == '21'
125 shell: bash 148 shell: bash
126 run: | 149 run: |
127 du -h -d1 . 150 du -h -d1 .
@@ -140,11 +163,13 @@ jobs: @@ -140,11 +163,13 @@ jobs:
140 readelf -d build/bin/sherpa-onnx 163 readelf -d build/bin/sherpa-onnx
141 164
142 - uses: actions/upload-artifact@v4 165 - uses: actions/upload-artifact@v4
  166 + if: matrix.java-version == '21'
143 with: 167 with:
144 - name: release-jni-linux 168 + name: release-jni-linux-${{ matrix.java-version }}
145 path: build/install/* 169 path: build/install/*
146 170
147 - name: Copy files 171 - name: Copy files
  172 + if: matrix.java-version == '21'
148 shell: bash 173 shell: bash
149 run: | 174 run: |
150 du -h -d1 . 175 du -h -d1 .
@@ -163,7 +188,7 @@ jobs: @@ -163,7 +188,7 @@ jobs:
163 du -h -d1 . 188 du -h -d1 .
164 189
165 - name: Publish to huggingface 190 - name: Publish to huggingface
166 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') 191 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && matrix.java-version == '21'
167 env: 192 env:
168 HF_TOKEN: ${{ secrets.HF_TOKEN }} 193 HF_TOKEN: ${{ secrets.HF_TOKEN }}
169 uses: nick-fields/retry@v3 194 uses: nick-fields/retry@v3
@@ -195,7 +220,7 @@ jobs: @@ -195,7 +220,7 @@ jobs:
195 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 220 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
196 221
197 - name: Release pre-compiled binaries and libs for linux x64 222 - name: Release pre-compiled binaries and libs for linux x64
198 - if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 223 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.java-version == '21'
199 uses: svenstaro/upload-release-action@v2 224 uses: svenstaro/upload-release-action@v2
200 with: 225 with:
201 file_glob: true 226 file_glob: true
@@ -78,7 +78,7 @@ jobs: @@ -78,7 +78,7 @@ jobs:
78 run: | 78 run: |
79 ./run-vad-asr.sh 79 ./run-vad-asr.sh
80 80
81 - - name: Release jar 81 + - name: Release
82 if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 82 if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
83 uses: svenstaro/upload-release-action@v2 83 uses: svenstaro/upload-release-action@v2
84 with: 84 with: