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
24 changes: 24 additions & 0 deletions .github/scripts/release-smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
# Smoke-test an installed release tree (cmake --install output): every binary
# resolves its libraries through the install rpath and starts. Needs no model.
# release-smoke.sh STAGE_DIR
# Runs on the host or inside a clean container (sh only, no bash).
set -eu
stage=$1
cd / # not the build tree: libraries must come from the rpath, not the cwd

if command -v ldd >/dev/null 2>&1; then
for f in "$stage"/bin/* "$stage"/lib/*.so; do
if ldd "$f" 2>/dev/null | grep -q "not found"; then
echo "missing libraries for $f:"; ldd "$f"; exit 1
fi
done
elif command -v otool >/dev/null 2>&1; then
for f in "$stage"/bin/*; do otool -L "$f"; done
fi

"$stage/bin/tts-cli" --version
if [ -x "$stage/bin/tts-server" ]; then "$stage/bin/tts-server" --version; fi
# codec-cli has no --version; its usage text proves it loaded.
"$stage/bin/codec-cli" 2>&1 | grep -q usage
echo "smoke ok: $stage"
25 changes: 20 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential pkg-config

sudo apt-get install -y cmake build-essential pkg-config ninja-build ccache

# Both ggml copies (codec.cpp's and the llama.cpp backbone's) compile
# through ccache once it is installed. A PR reads its own and main's caches.
- name: ccache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ccache-ci-${{ github.run_id }}
restore-keys: ccache-ci-

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build build --config ${{env.BUILD_TYPE}} -j$(nproc)
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 400M
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) # also caps the nested backbone build
cmake --build build
ccache -s

- name: Test CLI exists
run: |
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential pkg-config python3-pip ffmpeg sox
sudo apt-get install -y cmake build-essential pkg-config python3-pip ffmpeg sox ninja-build ccache

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -62,10 +62,22 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-e2e.txt

- name: ccache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ccache-e2e-${{ github.run_id }}
restore-keys: ccache-e2e-

# The codec smokes drive codec-cli and libcodec only: no llama.cpp backbone.
- name: Build C++
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 200M
run: |
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build build --config ${{env.BUILD_TYPE}} -j$(nproc)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCODEC_TTS_BACKBONE=OFF
cmake --build build --target codec-cli codec_shared -j$(nproc)
ccache -s

- name: Verify CLI
run: |
Expand Down
249 changes: 249 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
name: Release

# Prebuilt libraries + tools (codec-cli, tts-cli, tts-server).
# - push a tag v<version> -> build every package, then a DRAFT GitHub release
# (publish it by hand after a look)
# - workflow_dispatch, or a PR that touches this recipe
# -> build every package as workflow artifacts only
# Cutting a release: bump `project(codec VERSION ...)` in CMakeLists.txt and
# `__version__` in python/codec_cpp/__init__.py, merge, push the tag.
#
# Budget: standard GitHub-hosted runners only (free on a public repo), never on
# a plain push. No CUDA / ROCm / SYCL packages: Vulkan covers those GPUs, and
# their builds are the slow, large ones.
# Windows: clang-cl against the MSVC runtime (/MD); the VC++ runtime DLLs ship
# app-local in bin/, so a clean machine needs no redistributable installed.
#
# CPU baseline: one fixed ISA for both ggml copies (codec.cpp's and the
# llama.cpp backbone's; SetupTtsBackbone.cmake forwards every GGML_* option):
# x86-64 AVX2 (Haswell / Zen 1 and newer), arm64 armv8.2-a+fp16+dotprod.
# OpenMP off, so the binaries need no libgomp.

on:
push:
tags: [ 'v*' ]
workflow_dispatch:
pull_request:
paths: [ '.github/workflows/release.yml', '.github/scripts/release-smoke.sh' ]

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
CMAKE_COMMON: -G Ninja -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DGGML_OPENMP=OFF -DCMAKE_INSTALL_PREFIX=stage
VULKAN_SDK_TAG: vulkan-sdk-1.4.363.0 # Vulkan-Headers / SPIRV-Headers for the Android cross build
VULKAN_SDK_WIN: 1.4.313.2 # LunarG SDK for the Windows Vulkan package

jobs:
version:
runs-on: ubuntu-24.04
outputs:
name: ${{ steps.v.outputs.name }}
steps:
- uses: actions/checkout@v4
- id: v
name: Version name (tags must match CMakeLists.txt and the Python package)
run: |
cmake_v=$(sed -nE 's/^project\(codec VERSION ([0-9.]+).*/\1/p' CMakeLists.txt)
py_v=$(sed -nE 's/^__version__ = "([^"]+)"/\1/p' python/codec_cpp/__init__.py)
if [ "${GITHUB_REF_TYPE}" = tag ]; then
tag_v=${GITHUB_REF_NAME#v}
if [ "$tag_v" != "$cmake_v" ] || [ "$tag_v" != "$py_v" ]; then
echo "::error::tag $GITHUB_REF_NAME, CMakeLists.txt $cmake_v, python $py_v: bump both before tagging"
exit 1
fi
echo "name=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
else
echo "name=v$cmake_v-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi

build:
needs: version
timeout-minutes: 60 # longest job (Android) takes ~16 min; a stuck runner stops here
defaults:
run:
shell: bash
env:
# Both ggml copies compile through ccache once it is on PATH (ggml's
# GGML_CCACHE). A PR run reads its own earlier caches and main's.
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 500M
strategy:
fail-fast: false
matrix:
include:
- name: linux-x64-cpu
os: ubuntu-22.04 # glibc 2.35
defines: -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON -DGGML_AVX512=OFF
smoke_images: archlinux:latest ubuntu:22.04
- name: linux-x64-vulkan
os: ubuntu-22.04
defines: -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON -DGGML_AVX512=OFF -DGGML_VULKAN=ON
smoke_images: ubuntu:22.04
smoke_prep: apt-get update -qq && apt-get install -y -qq libvulkan1 >/dev/null &&
- name: linux-arm64-cpu
os: ubuntu-22.04-arm
defines: -DGGML_CPU_ARM_ARCH=armv8.2-a+fp16+dotprod
smoke_images: ubuntu:22.04 debian:12
- name: macos-arm64-metal
os: macos-15
defines: -DGGML_CPU_ARM_ARCH=armv8.2-a+fp16+dotprod -DGGML_METAL=ON -DGGML_METAL_EMBED_LIBRARY=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3
- name: android-arm64-vulkan
os: ubuntu-24.04
android: true
defines: -DGGML_CPU_ARM_ARCH=armv8.2-a+fp16+dotprod -DGGML_VULKAN=ON -DCODEC_TTS_SERVER=OFF
- name: windows-x64-cpu
os: windows-2022
defines: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON -DGGML_AVX512=OFF
- name: windows-x64-vulkan
os: windows-2022
defines: -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON -DGGML_AVX512=OFF -DGGML_VULKAN=ON
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1

- name: ccache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ccache-release-${{ matrix.name }}-${{ github.run_id }}
restore-keys: ccache-release-${{ matrix.name }}-

- name: Dependencies (Linux)
if: runner.os == 'Linux' && !matrix.android
run: |
if [[ "${{ matrix.name }}" == *vulkan ]]; then
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache vulkan-sdk
else
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache
fi

- name: Dependencies (macOS)
if: runner.os == 'macOS'
run: brew install ninja ccache

- name: Dependencies (Android)
if: matrix.android
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build ccache glslc
# The NDK ships libvulkan but not vulkan.hpp / SPIRV-Headers. SPIRV-Headers
# installs into the Vulkan-Headers tree: ggml includes spirv.hpp but takes
# its include path from Vulkan only.
vk="$RUNNER_TEMP/Vulkan-Headers"
git clone -q --depth 1 -b "$VULKAN_SDK_TAG" https://github.com/KhronosGroup/Vulkan-Headers "$vk"
git clone -q --depth 1 -b "$VULKAN_SDK_TAG" https://github.com/KhronosGroup/SPIRV-Headers "$RUNNER_TEMP/SPIRV-Headers"
cmake -S "$RUNNER_TEMP/SPIRV-Headers" -B "$RUNNER_TEMP/spirv-build" -DSPIRV_HEADERS_ENABLE_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX="$vk"
cmake --install "$RUNNER_TEMP/spirv-build"
echo "ANDROID_DEFINES=-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-28 \
-DVulkan_INCLUDE_DIR=$vk/include -DVulkan_GLSLC_EXECUTABLE=$(command -v glslc) \
-DSPIRV-Headers_DIR=$vk/share/cmake/SPIRV-Headers" >> "$GITHUB_ENV"

- name: MSVC environment (Windows)
if: runner.os == 'Windows'
shell: pwsh
# vcvars64 into the job environment, so the bash steps below build with
# the MSVC SDK, its Ninja and the LLVM clang-cl on the runner.
run: |
$vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
cmd /c "`"$vs\VC\Auxiliary\Build\vcvars64.bat`" >nul && set" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') { "$($matches[1])=$($matches[2])" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 }
}

- name: Dependencies (Windows)
if: runner.os == 'Windows'
run: choco install -y --no-progress ccache

- name: Dependencies (Windows Vulkan)
if: runner.os == 'Windows' && endsWith(matrix.name, 'vulkan')
shell: pwsh
run: |
curl.exe -sSLo "$env:RUNNER_TEMP\vulkansdk.exe" "https://sdk.lunarg.com/sdk/download/$env:VULKAN_SDK_WIN/windows/vulkansdk-windows-X64-$env:VULKAN_SDK_WIN.exe"
& "$env:RUNNER_TEMP\vulkansdk.exe" --accept-licenses --default-answer --confirm-command install | Out-Null
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\$env:VULKAN_SDK_WIN"
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\$env:VULKAN_SDK_WIN\bin"

- name: Configure
run: cmake -S . -B build $CMAKE_COMMON ${{ matrix.defines }} ${ANDROID_DEFINES:-}

- name: Build
# The env var also caps the nested llama.cpp backbone build.
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=${NUMBER_OF_PROCESSORS:-$(getconf _NPROCESSORS_ONLN)}
cmake --build build
ccache -s

- name: Install
run: cmake --install build --strip

- name: VC++ runtime, app-local (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Copy-Item "$env:VCToolsRedistDir\x64\Microsoft.VC*.CRT\*.dll" stage\bin\

- name: Smoke test (host)
if: ${{ !matrix.android }}
run: sh .github/scripts/release-smoke.sh "$PWD/stage"

- name: Smoke test (clean containers)
if: matrix.smoke_images
run: |
for img in ${{ matrix.smoke_images }}; do
echo "::group::$img"
docker run --rm -v "$PWD/stage:/opt/codec:ro" -v "$PWD/.github/scripts:/s:ro" "$img" \
sh -c '${{ matrix.smoke_prep }} sh /s/release-smoke.sh /opt/codec'
echo "::endgroup::"
done

- name: Package
run: |
pkg="codec-${{ needs.version.outputs.name }}-bin-${{ matrix.name }}"
mv stage "$pkg"
cp LICENSE README.md "$pkg/"
if [ "$RUNNER_OS" = Windows ]; then
7z a -bd "$pkg.zip" "$pkg" >/dev/null
echo "PKG=$pkg.zip" >> "$GITHUB_ENV"
else
tar -czf "$pkg.tar.gz" "$pkg"
echo "PKG=$pkg.tar.gz" >> "$GITHUB_ENV"
fi

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ env.PKG }}
retention-days: 7
compression-level: 0 # already compressed

release:
needs: [ version, build ]
if: github.ref_type == 'tag'
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
cd dist
sha256sum *.tar.gz *.zip > SHA256SUMS
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft \
--title "$GITHUB_REF_NAME" --generate-notes *.tar.gz *.zip SHA256SUMS
Loading
Loading