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:
Russell Gilbert 2026-02-28 07:39:45 +00:00
parent 5714b3a396
commit c201f40d65
4 changed files with 18 additions and 0 deletions

View file

@ -2,6 +2,7 @@
name = "rustylee" name = "rustylee"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
build = "build.rs"
[dependencies] [dependencies]
ctrlc = "3.5.2" ctrlc = "3.5.2"

14
src/rustylee/build.rs Normal file
View 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);
}

View file

@ -0,0 +1 @@
98

View file

@ -7,10 +7,12 @@ use std::sync::mpsc::{self, Receiver, Sender};
use std::{thread, time::Duration}; use std::{thread, time::Duration};
fn main() { fn main() {
let semantic_version = env!("CARGO_PKG_VERSION").to_string();
let shutdown_requested = Arc::new(AtomicBool::new(false)); let shutdown_requested = Arc::new(AtomicBool::new(false));
let s = shutdown_requested.clone(); let s = shutdown_requested.clone();
setup_logging(); setup_logging();
info!("RustyLee: {}", env!("FULL_VERSION"));
ctrlc::set_handler(move || { ctrlc::set_handler(move || {
info!("[Signal] Shutdown signal caught!"); info!("[Signal] Shutdown signal caught!");