Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,8 @@ jobs:
- name: Build without default features (cloud only)
run: cargo build --no-default-features --features cloud

- name: Generate C header
run: cargo build --all-features

- name: Upload C header
uses: actions/upload-artifact@v4
with:
name: tts_wrapper_header
path: include/tts_wrapper.h

release:
if: startsWith(github.ref, 'refs/tags/v')
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libspeechd-dev libclang-dev

- name: Build release
run: cargo build --release --all-features

- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --all-features

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
target/release/librust_tts_wrapper.a
target/release/librust_tts_wrapper.so
include/tts_wrapper.h
160 changes: 160 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Publish

on:
push:
tags: ["v*"]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
version:
name: Sync version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Update Cargo.toml version
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
- uses: actions/upload-artifact@v4
with:
name: version-sync
path: Cargo.toml

test:
name: Test
needs: version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: version-sync
- uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libspeechd-dev libclang-dev
- name: Clippy
run: cargo clippy --all-features -- -D warnings
- name: Test
run: cargo test --all-features
- name: Build cloud-only
run: cargo build --no-default-features --features cloud

build-native:
name: Build native (${{ matrix.target }})
needs: test
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
lib: rust_tts_wrapper.dll
- target: aarch64-pc-windows-msvc
os: windows-latest
lib: rust_tts_wrapper.dll
- target: x86_64-apple-darwin
os: macos-latest
lib: librust_tts_wrapper.dylib
- target: aarch64-apple-darwin
os: macos-latest
lib: librust_tts_wrapper.dylib
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
lib: librust_tts_wrapper.so
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
lib: librust_tts_wrapper.so
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: version-sync
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
- name: Install speech-dispatcher dev (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libspeechd-dev libclang-dev
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ matrix.lib }}
- name: Upload static library
uses: actions/upload-artifact@v4
with:
name: static-${{ matrix.target }}
path: target/${{ matrix.target }}/release/librust_tts_wrapper.a
if: runner.os != 'Windows'
- name: Upload MSVC import library
uses: actions/upload-artifact@v4
with:
name: static-${{ matrix.target }}
path: target/${{ matrix.target }}/release/rust_tts_wrapper.lib
if: runner.os == 'Windows'

publish-crate:
name: crates.io
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: version-sync
- uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libspeechd-dev libclang-dev
- name: Publish
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-github-release:
name: GitHub Release
needs: [build-native]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
pattern: "{native-*,static-*}"
merge-multiple: true
- name: Organize release assets
run: |
mkdir -p release-assets
# Shared libraries
for f in artifacts/rust_tts_wrapper.dll artifacts/librust_tts_wrapper.dylib artifacts/librust_tts_wrapper.so; do
[ -f "$f" ] && cp "$f" release-assets/ 2>/dev/null || true
done
# Static libraries / import libs
for f in artifacts/librust_tts_wrapper.a artifacts/rust_tts_wrapper.lib; do
[ -f "$f" ] && cp "$f" release-assets/ 2>/dev/null || true
done
# C header
cp include/tts_wrapper.h release-assets/
ls -la release-assets/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: release-assets/*
fail_on_unmatched_files: false
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["cdylib", "staticlib", "lib"]
[features]
default = ["system", "cloud", "sherpaonnx"]
system = ["speech-dispatcher"]
cloud = ["reqwest", "serde_json"]
cloud = ["reqwest", "serde_json", "base64", "speechmarkdown-rust"]
sherpaonnx = ["sherpa-onnx"]

[dependencies]
Expand All @@ -23,6 +23,8 @@ reqwest = { version = "0.12", features = ["blocking", "json", "rustls-tls"], def
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", optional = true }
sherpa-onnx = { version = "1.13", optional = true }
base64 = { version = "0.22", optional = true }
speechmarkdown-rust = { version = "0.1", optional = true }
anyhow = "1"

[build-dependencies]
Expand Down
Loading
Loading