Implements automated build numbering
Introduces a build script to automatically increment a build number with each compilation. This number is combined with the semantic version to create a full version string. The full version is then exposed to the application and logged at startup, providing a unique identifier for each build to aid in tracking and debugging.
This commit is contained in:
parent
5714b3a396
commit
c201f40d65
4 changed files with 18 additions and 0 deletions
|
|
@ -2,6 +2,7 @@
|
|||
name = "rustylee"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
ctrlc = "3.5.2"
|
||||
|
|
|
|||
14
src/rustylee/build.rs
Normal file
14
src/rustylee/build.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||
let mut content = fs::read_to_string("build_number.txt").unwrap_or("0".to_string());
|
||||
let mut build_num: u32 = content.trim().parse().unwrap_or(0);
|
||||
|
||||
build_num += 1;
|
||||
let full_version = format!("{}.{}", pkg_version, build_num);
|
||||
|
||||
fs::write("build_number.txt", build_num.to_string()).unwrap();
|
||||
|
||||
println!("cargo:rustc-env=FULL_VERSION={}", full_version);
|
||||
}
|
||||
1
src/rustylee/build_number.txt
Normal file
1
src/rustylee/build_number.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
98
|
||||
|
|
@ -7,10 +7,12 @@ use std::sync::mpsc::{self, Receiver, Sender};
|
|||
use std::{thread, time::Duration};
|
||||
|
||||
fn main() {
|
||||
let semantic_version = env!("CARGO_PKG_VERSION").to_string();
|
||||
let shutdown_requested = Arc::new(AtomicBool::new(false));
|
||||
let s = shutdown_requested.clone();
|
||||
|
||||
setup_logging();
|
||||
info!("RustyLee: {}", env!("FULL_VERSION"));
|
||||
|
||||
ctrlc::set_handler(move || {
|
||||
info!("[Signal] Shutdown signal caught!");
|
||||
|
|
|
|||
Loading…
Reference in a new issue