diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 988b98fb29d48..b4688abe97b24 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -590,6 +590,7 @@ set (onnxruntime_shared_lib_test_SRC ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_run_options.cc ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_runtime_path.cc ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_session_options.cc + ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/test_version.cc ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.h ${ONNXRUNTIME_SHARED_LIB_TEST_SRC_DIR}/utils.cc ) diff --git a/docs/Versioning.md b/docs/Versioning.md index a8d26f7d74185..904e4f777561e 100644 --- a/docs/Versioning.md +++ b/docs/Versioning.md @@ -57,13 +57,19 @@ npm --version # Should be v8.0 or newer Replace `X.Y.Z` with your new version number. The comments following this assert explain additional steps if new APIs were added to this release. -4. **Review all changes** +4. **Update the C API header `ORT_API_VERSION` value (Manual Step)** + + The script does **not** update the value of `ORT_API_VERSION` in [include/onnxruntime/core/session/onnxruntime_c_api.h](../include/onnxruntime/core/session/onnxruntime_c_api.h). + + The value should be set to the second component of the version string. E.g., `25` for version `1.25.0`. + +5. **Review all changes** Review all modified files. Verify: - Version numbers are correct in all updated files - The release notes URL format is correct (e.g., `https://github.com/Microsoft/onnxruntime/releases/tag/vX.Y.Z`) -5. **Commit and create PR** +6. **Commit and create PR** Commit all changes and create a PR targeting `main` or a release branch as appropriate. diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 221f3673f2027..77c2ff795e800 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -38,7 +38,7 @@ * * This value is used by some API functions to behave as this version of the header expects. */ -#define ORT_API_VERSION 24 +#define ORT_API_VERSION 25 #ifdef __cplusplus extern "C" { diff --git a/onnxruntime/test/shared_lib/test_version.cc b/onnxruntime/test/shared_lib/test_version.cc new file mode 100644 index 0000000000000..5427378e7788a --- /dev/null +++ b/onnxruntime/test/shared_lib/test_version.cc @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#include "core/session/onnxruntime_cxx_api.h" + +#include +#include +#include +#include +#include + +#include "absl/strings/str_split.h" +#include "gtest/gtest.h" + +TEST(CApiTest, VersionConsistencyWithApiVersion) { + const auto version_string = Ort::GetVersionString(); + const std::vector version_string_components = absl::StrSplit(version_string, '.'); + ASSERT_EQ(version_string_components.size(), size_t{3}); + + auto to_uint32_t = [](const std::string& s) -> std::optional { + uint32_t result{}; + if (std::from_chars(s.data(), s.data() + s.size(), result).ec == std::errc{}) { + return result; + } + return std::nullopt; + }; + + ASSERT_NE(to_uint32_t(version_string_components[0]), std::nullopt); + ASSERT_EQ(to_uint32_t(version_string_components[1]), uint32_t{ORT_API_VERSION}); + ASSERT_NE(to_uint32_t(version_string_components[0]), std::nullopt); +}