Skip to content
Draft
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
12 changes: 11 additions & 1 deletion rust/release_crates/substitute_rust_release_version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading