Fangjun Kuang
Committed by GitHub

Publish pre-built macos xcframework (#1490)

@@ -4,6 +4,8 @@ on: @@ -4,6 +4,8 @@ on:
4 push: 4 push:
5 branches: 5 branches:
6 - master 6 - master
  7 + tags:
  8 + - 'v[0-9]+.[0-9]+.[0-9]+*'
7 paths: 9 paths:
8 - './build-swift-macos.sh' 10 - './build-swift-macos.sh'
9 - '.github/workflows/swift.yaml' 11 - '.github/workflows/swift.yaml'
@@ -65,6 +67,30 @@ jobs: @@ -65,6 +67,30 @@ jobs:
65 67
66 ./build-swift-macos.sh 68 ./build-swift-macos.sh
67 69
  70 + - name: Copy files
  71 + if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  72 + shell: bash
  73 + run: |
  74 + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
  75 +
  76 + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-xcframework-static
  77 + mkdir $dst
  78 +
  79 + mv -v build-swift-macos/sherpa-onnx.xcframework $dst
  80 +
  81 + brew install tree
  82 + tree $dst
  83 +
  84 + tar cjvf ${dst}.tar.bz2 $dst
  85 +
  86 + - name: Release pre-compiled binaries and libs for macOS
  87 + if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  88 + uses: svenstaro/upload-release-action@v2
  89 + with:
  90 + file_glob: true
  91 + overwrite: true
  92 + file: sherpa-onnx-*macos-xcframework-static.tar.bz2
  93 +
68 - name: test 94 - name: test
69 shell: bash 95 shell: bash
70 run: | 96 run: |
@@ -7,6 +7,9 @@ mkdir -p $dir @@ -7,6 +7,9 @@ mkdir -p $dir
7 cd $dir 7 cd $dir
8 8
9 cmake \ 9 cmake \
  10 + -DSHERPA_ONNX_ENABLE_BINARY=OFF \
  11 + -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
  12 + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
10 -DCMAKE_INSTALL_PREFIX=./install \ 13 -DCMAKE_INSTALL_PREFIX=./install \
11 -DCMAKE_BUILD_TYPE=Release \ 14 -DCMAKE_BUILD_TYPE=Release \
12 -DBUILD_SHARED_LIBS=OFF \ 15 -DBUILD_SHARED_LIBS=OFF \
@@ -21,6 +24,7 @@ cmake \ @@ -21,6 +24,7 @@ cmake \
21 24
22 make VERBOSE=1 -j4 25 make VERBOSE=1 -j4
23 make install 26 make install
  27 +rm -fv ./install/include/cargs.h
24 28
25 libtool -static -o ./install/lib/libsherpa-onnx.a \ 29 libtool -static -o ./install/lib/libsherpa-onnx.a \
26 ./install/lib/libsherpa-onnx-c-api.a \ 30 ./install/lib/libsherpa-onnx-c-api.a \
@@ -34,3 +38,8 @@ libtool -static -o ./install/lib/libsherpa-onnx.a \ @@ -34,3 +38,8 @@ libtool -static -o ./install/lib/libsherpa-onnx.a \
34 ./install/lib/libpiper_phonemize.a \ 38 ./install/lib/libpiper_phonemize.a \
35 ./install/lib/libespeak-ng.a \ 39 ./install/lib/libespeak-ng.a \
36 ./install/lib/libssentencepiece_core.a 40 ./install/lib/libssentencepiece_core.a
  41 +
  42 +xcodebuild -create-xcframework \
  43 + -library install/lib/libsherpa-onnx.a \
  44 + -headers install/include \
  45 + -output sherpa-onnx.xcframework
@@ -315,4 +315,3 @@ class SHERPA_ONNX_API OfflineRecognizer @@ -315,4 +315,3 @@ class SHERPA_ONNX_API OfflineRecognizer
315 } // namespace sherpa_onnx::cxx 315 } // namespace sherpa_onnx::cxx
316 316
317 #endif // SHERPA_ONNX_C_API_CXX_API_H_ 317 #endif // SHERPA_ONNX_C_API_CXX_API_H_
318 - //