From 62d7a20dbd45f8cd8fd08fb138f805138284ecf1 Mon Sep 17 00:00:00 2001 From: Stephen DeRosa Date: Mon, 11 May 2026 13:03:22 -0600 Subject: [PATCH 1/2] proper reporting of rust version based on git commit hash - build-info --- .github/workflows/builds.yml | 2 + .github/workflows/docker-images.yml | 3 +- .github/workflows/make-release.yml | 54 ++++++++++++++++++++++ CMakeLists.txt | 40 ++++++++++++++-- build-info.json.in | 8 ++++ client-sdk-rust | 2 +- docker/Dockerfile.sdk | 4 +- src/ffi_client.cpp | 2 +- src/tests/unit/test_sdk_initialization.cpp | 10 ++++ 9 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 build-info.json.in diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index e79bcde8..0d75d975 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -14,6 +14,7 @@ on: - CMakeLists.txt - build.sh - build.cmd + - build-info.json.in - vcpkg.json - CMakePresets.json - docker/Dockerfile.base @@ -34,6 +35,7 @@ on: - CMakeLists.txt - build.sh - build.cmd + - build-info.json.in - vcpkg.json - CMakePresets.json - docker/Dockerfile.base diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml index ebdae31d..6572ef47 100644 --- a/.github/workflows/docker-images.yml +++ b/.github/workflows/docker-images.yml @@ -12,6 +12,7 @@ on: - build.sh - build.cmd - build.h.in + - build-info.json.in - CMakePresets.json - cmake/** - data/** @@ -89,7 +90,7 @@ jobs: fi case "${path}" in - docker/Dockerfile.sdk|src/*|include/*|bridge/*|client-sdk-rust/*|cmake/*|data/*|CMakeLists.txt|build.sh|build.cmd|build.h.in|CMakePresets.json) + docker/Dockerfile.sdk|src/*|include/*|bridge/*|client-sdk-rust/*|cmake/*|data/*|CMakeLists.txt|build.sh|build.cmd|build.h.in|build-info.json.in|CMakePresets.json) sdk_changed=true ;; esac diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml index d1c94550..4ea5e4cc 100644 --- a/.github/workflows/make-release.yml +++ b/.github/workflows/make-release.yml @@ -182,6 +182,27 @@ jobs: echo "Bundle contents:" find "$bundleDir" -type f | head -120 + - name: Validate bundle version metadata (Unix) + if: runner.os != 'Windows' + shell: bash + run: | + set -euo pipefail + version="${{ steps.version.outputs.version }}" + bundleDir="sdk-out/livekit-sdk-${{ matrix.name }}-${version}" + header="${bundleDir}/include/livekit/build.h" + buildInfo="${bundleDir}/share/livekit/build-info.json" + + test -f "$header" + test -f "$buildInfo" + grep -F "#define LIVEKIT_BUILD_VERSION \"${version}\"" "$header" + if grep -F '#define LIVEKIT_BUILD_VERSION "0.0.0"' "$header"; then + echo "ERROR: bundle reports fallback SDK version" + exit 1 + fi + grep -F "\"sdk_version\": \"${version}\"" "$buildInfo" + grep -Eq '"rust_submodule_commit": "[0-9a-f]{7,}"' "$buildInfo" + grep -Eq '"livekit_ffi_version": "[0-9]+\.[0-9]+\.[0-9]+' "$buildInfo" + # ---------- Build + Bundle (Windows) ---------- - name: Build and Bundle (Windows) if: runner.os == 'Windows' @@ -243,6 +264,39 @@ jobs: } python .github/scripts/check_no_private_symbols.py "$lib" + - name: Validate bundle version metadata (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + $version = "${{ steps.version.outputs.version }}" + $bundleDir = "sdk-out/livekit-sdk-${{ matrix.name }}-$version" + $header = Join-Path $bundleDir "include/livekit/build.h" + $buildInfo = Join-Path $bundleDir "share/livekit/build-info.json" + + if (!(Test-Path $header)) { throw "Missing $header" } + if (!(Test-Path $buildInfo)) { throw "Missing $buildInfo" } + + $headerText = Get-Content -Raw $header + $expectedHeaderVersion = "#define LIVEKIT_BUILD_VERSION `"$version`"" + if (!$headerText.Contains($expectedHeaderVersion)) { + throw "Header does not report expected SDK version $version" + } + if ($headerText.Contains('#define LIVEKIT_BUILD_VERSION "0.0.0"')) { + throw "Bundle reports fallback SDK version" + } + + $buildInfoText = Get-Content -Raw $buildInfo + $expectedBuildInfoVersion = "`"sdk_version`": `"$version`"" + if (!$buildInfoText.Contains($expectedBuildInfoVersion)) { + throw "Build info does not report expected SDK version $version" + } + if ($buildInfoText -match '"rust_submodule_commit": "unknown"') { + throw "Build info is missing Rust submodule commit" + } + if ($buildInfoText -match '"livekit_ffi_version": "unknown"') { + throw "Build info is missing livekit-ffi version" + } + # ---------- Upload artifact (raw directory, no pre-compression) ---------- - name: Upload build artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f71c956..a9bf9b1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,12 @@ if(NOT DEFINED LIVEKIT_VERSION OR LIVEKIT_VERSION STREQUAL "") set(LIVEKIT_VERSION "0.0.0") endif() -project(livekit VERSION ${LIVEKIT_VERSION} LANGUAGES C CXX) +string(REGEX MATCH "^[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*" LIVEKIT_PROJECT_VERSION "${LIVEKIT_VERSION}") +if(LIVEKIT_PROJECT_VERSION STREQUAL "") + message(FATAL_ERROR "LIVEKIT_VERSION must start with a numeric version, got '${LIVEKIT_VERSION}'") +endif() + +project(livekit VERSION ${LIVEKIT_PROJECT_VERSION} LANGUAGES C CXX) set(LIVEKIT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIVEKIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -144,8 +149,11 @@ target_sources(livekit_proto PRIVATE ${PROTO_SRCS} ${PROTO_HDRS}) # Generate build.h directly into include/livekit/ for simpler include paths set(GENERATED_BUILD_H "${LIVEKIT_ROOT_DIR}/include/livekit/build.h") +set(GENERATED_BUILD_INFO_JSON "${LIVEKIT_BINARY_DIR}/build-info.json") +set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust) set(GIT_COMMIT "unknown") +set(RUST_GIT_COMMIT "unknown") find_package(Git QUIET) if(GIT_FOUND AND EXISTS "${LIVEKIT_ROOT_DIR}/.git") execute_process( @@ -156,6 +164,25 @@ if(GIT_FOUND AND EXISTS "${LIVEKIT_ROOT_DIR}/.git") ERROR_QUIET ) endif() +if(GIT_FOUND AND EXISTS "${RUST_ROOT}/.git") + execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD + WORKING_DIRECTORY "${RUST_ROOT}" + OUTPUT_VARIABLE RUST_GIT_COMMIT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) +endif() + +set(LIVEKIT_FFI_VERSION "unknown") +set(LIVEKIT_FFI_CARGO_TOML "${RUST_ROOT}/livekit-ffi/Cargo.toml") +if(EXISTS "${LIVEKIT_FFI_CARGO_TOML}") + file(READ "${LIVEKIT_FFI_CARGO_TOML}" LIVEKIT_FFI_CARGO_TOML_CONTENTS) + string(REGEX MATCH "version[ \t]*=[ \t]*\"([^\"]+)\"" _LIVEKIT_FFI_VERSION_MATCH "${LIVEKIT_FFI_CARGO_TOML_CONTENTS}") + if(_LIVEKIT_FFI_VERSION_MATCH) + set(LIVEKIT_FFI_VERSION "${CMAKE_MATCH_1}") + endif() +endif() string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") set(GENERATED_COMMENT "This file was auto-generated by CMake on ${BUILD_DATE}. Do NOT edit manually.") @@ -165,11 +192,14 @@ configure_file( "${GENERATED_BUILD_H}" @ONLY ) +configure_file( + "${LIVEKIT_ROOT_DIR}/build-info.json.in" + "${GENERATED_BUILD_INFO_JSON}" + @ONLY +) find_program(CARGO_EXECUTABLE NAMES cargo REQUIRED) -set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust) - # Determine Rust target triple for cross-compilation on macOS set(RUST_TARGET_TRIPLE "") if(APPLE AND CMAKE_OSX_ARCHITECTURES) @@ -583,6 +613,10 @@ include(CMakePackageConfigHelpers) set(LIVEKIT_PACKAGE_NAME "LiveKit") set(LIVEKIT_EXPORT_NAMESPACE "LiveKit::") +install(FILES "${GENERATED_BUILD_INFO_JSON}" + DESTINATION "${CMAKE_INSTALL_DATADIR}/livekit" +) + # Install the library target install(TARGETS livekit EXPORT LiveKitTargets diff --git a/build-info.json.in b/build-info.json.in new file mode 100644 index 00000000..7dd75637 --- /dev/null +++ b/build-info.json.in @@ -0,0 +1,8 @@ +{ + "sdk": "cpp", + "sdk_version": "@LIVEKIT_VERSION@", + "cpp_git_commit": "@GIT_COMMIT@", + "rust_submodule_commit": "@RUST_GIT_COMMIT@", + "livekit_ffi_version": "@LIVEKIT_FFI_VERSION@", + "build_date": "@BUILD_DATE@" +} diff --git a/client-sdk-rust b/client-sdk-rust index f3064cd4..b31cf118 160000 --- a/client-sdk-rust +++ b/client-sdk-rust @@ -1 +1 @@ -Subproject commit f3064cd4b091b7f8cb5fa38b469bf3389edcadb9 +Subproject commit b31cf118fb8e2ff2a35641814afbdf2d4a56dd04 diff --git a/docker/Dockerfile.sdk b/docker/Dockerfile.sdk index 803a0a5d..da8aa5fe 100644 --- a/docker/Dockerfile.sdk +++ b/docker/Dockerfile.sdk @@ -20,6 +20,7 @@ ARG BASE_IMAGE=livekit-cpp-sdk-base FROM ${BASE_IMAGE} +ARG LIVEKIT_VERSION=0.0.0 ENV SDK_INSTALL_PREFIX=/opt/livekit-sdk # Copy project source (build context = repo root) @@ -36,6 +37,7 @@ COPY data /client-sdk-cpp/data COPY cmake /client-sdk-cpp/cmake COPY CMakeLists.txt /client-sdk-cpp/CMakeLists.txt COPY build.h.in /client-sdk-cpp/build.h.in +COPY build-info.json.in /client-sdk-cpp/build-info.json.in # Configure Rust linker: use full GCC path so liblto_plugin.so is found (not /home/installs/ which has no plugin) RUN mkdir -p /client-sdk-cpp/client-sdk-rust/.cargo \ @@ -50,5 +52,5 @@ RUN LLVM_VERSION="$(llvm-config --version | cut -d. -f1)" \ && export CFLAGS="-Wno-deprecated-declarations" \ && chmod +x /client-sdk-cpp/build.sh \ && cd /client-sdk-cpp \ - && ./build.sh release --bundle --prefix "${SDK_INSTALL_PREFIX}" \ + && ./build.sh release --version "${LIVEKIT_VERSION}" --bundle --prefix "${SDK_INSTALL_PREFIX}" \ && test -f "${SDK_INSTALL_PREFIX}/lib/cmake/LiveKit/LiveKitConfig.cmake" diff --git a/src/ffi_client.cpp b/src/ffi_client.cpp index f18c87aa..d0b2af55 100644 --- a/src/ffi_client.cpp +++ b/src/ffi_client.cpp @@ -163,7 +163,7 @@ bool FfiClient::initialize(bool capture_logs) { return false; } initialized_.store(true, std::memory_order_release); - livekit_ffi_initialize(&LivekitFfiCallback, capture_logs, LIVEKIT_BUILD_FLAVOR, LIVEKIT_BUILD_VERSION_FULL); + livekit_ffi_initialize(&LivekitFfiCallback, capture_logs, LIVEKIT_BUILD_FLAVOR, LIVEKIT_BUILD_VERSION); return true; } diff --git a/src/tests/unit/test_sdk_initialization.cpp b/src/tests/unit/test_sdk_initialization.cpp index 23d8e6b8..45137dc9 100644 --- a/src/tests/unit/test_sdk_initialization.cpp +++ b/src/tests/unit/test_sdk_initialization.cpp @@ -17,6 +17,8 @@ #include #include +#include + namespace livekit::test { class SDKInitializationTest : public ::testing::Test { @@ -65,4 +67,12 @@ TEST_F(SDKInitializationTest, MultipleShutdowns) { EXPECT_NO_THROW(livekit::shutdown()); } +TEST(SDKBuildInfoTest, ServerFacingVersionDoesNotIncludeBuildFlavorSuffix) { + const std::string version = LIVEKIT_BUILD_VERSION; + + EXPECT_FALSE(version.empty()); + EXPECT_EQ(version.find("-debug"), std::string::npos); + EXPECT_EQ(version.find("-release"), std::string::npos); +} + } // namespace livekit::test From cb091f6712550f3216ca315637c05b79df6538f4 Mon Sep 17 00:00:00 2001 From: Stephen DeRosa Date: Tue, 12 May 2026 16:47:22 -0600 Subject: [PATCH 2/2] update rust hash --- client-sdk-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-sdk-rust b/client-sdk-rust index b31cf118..8d4d069a 160000 --- a/client-sdk-rust +++ b/client-sdk-rust @@ -1 +1 @@ -Subproject commit b31cf118fb8e2ff2a35641814afbdf2d4a56dd04 +Subproject commit 8d4d069ac6b47e610160bf44b8891a730ce91154