Skip to content

Commit

Permalink
Handle Versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
mkysel committed Dec 20, 2024
1 parent a0791f0 commit 613ef79
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 10 deletions.
70 changes: 64 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ thiserror = "2.0"
tls_codec = "0.4.1"
tokio = { version = "1.35.1", default-features = false }
uuid = "1.10"
vergen-git2 = "1.0.2"
wasm-timer = "0.2"
web-time = "1.1"
# Changing this version and rustls may potentially break the android build. Use Caution.
Expand Down
2 changes: 1 addition & 1 deletion mls_validation_service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "mls-validation-service"
path = "src/main.rs"

[build-dependencies]
vergen = { version = "8.3.2", features = ["git", "git2"] }
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
Expand Down
14 changes: 11 additions & 3 deletions mls_validation_service/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use vergen::EmitBuilder;
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() {
EmitBuilder::builder().git_sha(true).emit().unwrap();
fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
// this is a change
3 changes: 3 additions & 0 deletions xmtp_debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
version = "0.1.0"
license.workspace = true

[build-dependencies]
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
clap-verbosity-flag = "3.0"
Expand Down
12 changes: 12 additions & 0 deletions xmtp_debug/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
3 changes: 3 additions & 0 deletions xmtp_debug/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub use types::*;
/// Debug & Generate data on the XMTP Network
#[derive(Parser, Debug)]
pub struct AppOpts {
// Print Version
#[arg(long)]
pub version: bool,
#[command(subcommand)]
pub cmd: Option<Commands>,
#[command(flatten)]
Expand Down
9 changes: 9 additions & 0 deletions xmtp_debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ async fn main() -> Result<()> {
let mut logger = logger::Logger::from(&opts.log);
logger.init()?;

if opts.version {
info!("Version: {0}", get_version());
return Ok(());
}

let app = app::App::new(opts)?;
app.run().await?;

Ok(())
}

pub fn get_version() -> String {
format!("{}-{}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"))
}

0 comments on commit 613ef79

Please sign in to comment.