diff --git a/rust/release_crates/substitute_rust_release_version.bzl b/rust/release_crates/substitute_rust_release_version.bzl index e0ea9ce5f8952..cfe2cc8ff5e88 100644 --- a/rust/release_crates/substitute_rust_release_version.bzl +++ b/rust/release_crates/substitute_rust_release_version.bzl @@ -2,10 +2,20 @@ load("//:protobuf_version.bzl", "PROTOBUF_RUST_VERSION") +def _get_minor_version(version_str): + parts = version_str.split(".") + if len(parts) < 2: + return 0 + return int(parts[1]) + +_minor_version = _get_minor_version(PROTOBUF_RUST_VERSION) + # Temporarily append a -release suffix to non-RC versions until we consider the # release stable. Since "release" lexicographically comes after "rc", Cargo # will understand that 4.31.0-release is newer than all 4.31.0-rc.N releases. -PROTOBUF_RUST_VERSION_SUFFIX = "-release" if PROTOBUF_RUST_VERSION.find("-rc") == -1 else "" +# Remove the -release tag only if the minor version number is >= 36. +_should_append_release = _minor_version < 36 and PROTOBUF_RUST_VERSION.find("-rc") == -1 +PROTOBUF_RUST_VERSION_SUFFIX = "-release" if _should_append_release else "" def substitute_rust_release_version(src, out, name = None): version = PROTOBUF_RUST_VERSION + PROTOBUF_RUST_VERSION_SUFFIX