Skip to content

Commit

Permalink
add profile to version
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Jan 15, 2025
1 parent 786521d commit 92ba0d9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/common/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
// 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: <BIN> 0.3.0-dev+ba03de0019
// if on a tag: <BIN> 0.3.0-stable+ba03de0019
// if not on a tag: <BIN> 0.3.0-dev+ba03de0019.debug
// if on a tag: <BIN> 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()),
Expand All @@ -26,11 +27,17 @@ pub fn set_build_version() -> Result<(), Box<dyn Error>> {
// 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(())
}

0 comments on commit 92ba0d9

Please sign in to comment.