From 92ba0d9280c8ebe77b62bf3e8c94618424143c2c Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Wed, 15 Jan 2025 17:36:04 +0100 Subject: [PATCH] add profile to version --- crates/common/src/version.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/common/src/version.rs b/crates/common/src/version.rs index 147efa3416a0..e0a70f0b23ab 100644 --- a/crates/common/src/version.rs +++ b/crates/common/src/version.rs @@ -8,11 +8,12 @@ pub const NIGHTLY_VERSION_WARNING_MESSAGE: &str = #[allow(clippy::disallowed_macros)] /// Set the build version information for Foundry binaries. pub fn set_build_version() -> Result<(), Box> { + // Set the short Git SHA of the latest commit. let sha = env::var("VERGEN_GIT_SHA")?; // Set the version suffix and whether the version is a nightly build. - // if not on a tag: 0.3.0-dev+ba03de0019 - // if on a tag: 0.3.0-stable+ba03de0019 + // if not on a tag: 0.3.0-dev+ba03de0019.debug + // if on a tag: 0.3.0-stable+ba03de0019.release let tag_name = option_env!("TAG_NAME"); let (is_nightly, version_suffix) = match tag_name { Some(tag_name) if tag_name.eq("nightly") => (true, "-nightly".to_string()), @@ -26,11 +27,17 @@ pub fn set_build_version() -> Result<(), Box> { // Set formatted version strings let pkg_version = env!("CARGO_PKG_VERSION"); + // Append the profile to the version string if it exists. + let profile_suffix = + env::var("PROFILE").map_or(String::new(), |profile| format!(".{}", profile)); + // The short version information for Foundry. // - The latest version from Cargo.toml // - The short SHA of the latest commit. - // Example: 0.3.0-dev+ba03de0019 - println!("cargo:rustc-env=FOUNDRY_SHORT_VERSION={pkg_version}{version_suffix}+{sha}"); + // Example: 0.3.0-dev+ba03de0019.debug + println!( + "cargo:rustc-env=FOUNDRY_SHORT_VERSION={pkg_version}{version_suffix}+{sha}{profile_suffix}" + ); Ok(()) }