Skip to content

Commit ebb2394

Browse files
committed
Update to print full version string
1 parent cd2cb5d commit ebb2394

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

stacks-signer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ clarity = { path = "../clarity" }
2525
clap = { version = "4.1.1", features = ["derive", "env"] }
2626
hashbrown = { workspace = true }
2727
lazy_static = "1.4.0"
28+
once_cell = "1.8.0"
2829
libsigner = { path = "../libsigner" }
2930
libstackerdb = { path = "../libstackerdb" }
3031
prometheus = { version = "0.9", optional = true }

stacks-signer/src/cli.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,36 @@ use stacks_common::address::{
3737
};
3838
use stacks_common::define_u8_enum;
3939
use stacks_common::types::chainstate::StacksPrivateKey;
40+
use once_cell::sync::Lazy;
4041

4142
extern crate alloc;
4243

44+
const GIT_BRANCH: Option<&'static str> = option_env!("GIT_BRANCH");
45+
const GIT_COMMIT: Option<&'static str> = option_env!("GIT_COMMIT");
46+
#[cfg(debug_assertions)]
47+
const BUILD_TYPE: &'static str = "debug";
48+
#[cfg(not(debug_assertions))]
49+
const BUILD_TYPE: &'static str = "release";
50+
51+
52+
static VERSION_STRING: Lazy<String> = Lazy::new(|| {
53+
let pkg_version = option_env!("STACKS_NODE_VERSION").unwrap_or(env!("CARGO_PKG_VERSION"));
54+
let git_branch = GIT_BRANCH.unwrap_or("");
55+
let git_commit = GIT_COMMIT.unwrap_or("");
56+
format!(
57+
"{} ({}:{}, {} build, {} [{}])",
58+
pkg_version,
59+
git_branch,
60+
git_commit,
61+
BUILD_TYPE,
62+
std::env::consts::OS,
63+
std::env::consts::ARCH
64+
)
65+
});
66+
4367
#[derive(Parser, Debug)]
4468
#[command(author, version, about)]
45-
#[command(long_version = option_env!("SIGNER_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")))]
69+
#[command(long_version = VERSION_STRING.as_str())]
4670

4771
/// The CLI arguments for the stacks signer
4872
pub struct Cli {

0 commit comments

Comments
 (0)