diff --git a/.github/workflows/swift.yaml b/.github/workflows/swift.yaml index 3176c9b31..2143dccde 100644 --- a/.github/workflows/swift.yaml +++ b/.github/workflows/swift.yaml @@ -4,6 +4,8 @@ on: push: branches: - master + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' paths: - './build-swift-macos.sh' - '.github/workflows/swift.yaml' @@ -65,6 +67,30 @@ jobs: ./build-swift-macos.sh + - name: Copy files + if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + shell: bash + run: | + SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) + + dst=sherpa-onnx-${SHERPA_ONNX_VERSION}-macos-xcframework-static + mkdir $dst + + mv -v build-swift-macos/sherpa-onnx.xcframework $dst + + brew install tree + tree $dst + + tar cjvf ${dst}.tar.bz2 $dst + + - name: Release pre-compiled binaries and libs for macOS + if: matrix.os == 'macos-13' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + file_glob: true + overwrite: true + file: sherpa-onnx-*macos-xcframework-static.tar.bz2 + - name: test shell: bash run: | diff --git a/build-swift-macos.sh b/build-swift-macos.sh index f41dd7d5c..359ea9371 100755 --- a/build-swift-macos.sh +++ b/build-swift-macos.sh @@ -7,6 +7,9 @@ mkdir -p $dir cd $dir cmake \ + -DSHERPA_ONNX_ENABLE_BINARY=OFF \ + -DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ -DCMAKE_INSTALL_PREFIX=./install \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_SHARED_LIBS=OFF \ @@ -21,6 +24,7 @@ cmake \ make VERBOSE=1 -j4 make install +rm -fv ./install/include/cargs.h libtool -static -o ./install/lib/libsherpa-onnx.a \ ./install/lib/libsherpa-onnx-c-api.a \ @@ -34,3 +38,8 @@ libtool -static -o ./install/lib/libsherpa-onnx.a \ ./install/lib/libpiper_phonemize.a \ ./install/lib/libespeak-ng.a \ ./install/lib/libssentencepiece_core.a + +xcodebuild -create-xcframework \ + -library install/lib/libsherpa-onnx.a \ + -headers install/include \ + -output sherpa-onnx.xcframework diff --git a/sherpa-onnx/c-api/cxx-api.h b/sherpa-onnx/c-api/cxx-api.h index b8a46e113..ade52b9aa 100644 --- a/sherpa-onnx/c-api/cxx-api.h +++ b/sherpa-onnx/c-api/cxx-api.h @@ -315,4 +315,3 @@ class SHERPA_ONNX_API OfflineRecognizer } // namespace sherpa_onnx::cxx #endif // SHERPA_ONNX_C_API_CXX_API_H_ - //