feat: git-based nightly versions

This commit is contained in:
2026-08-07 23:20:42 -04:00
parent 673a11b320
commit 28d63c14e3
11 changed files with 62 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: Prosperity-3.0.0
// Copyright Scientific Computing Studio
// Source: https://git.scient.ing/education/coursebank
//! Chooses the version string compiled into the binary.
//!
//! Normal and release builds use the version from `Cargo.toml`. Nightly builds
//! set `COURSEBANK_VERSION` (to a git-derived string; see
//! `scripts/nightly-version.sh`) so `coursebank --version` reflects how far the
//! build is past the last release rather than an unreleased number.
use std::env;
fn main() {
let version = match env::var("COURSEBANK_VERSION") {
Ok(v) if !v.trim().is_empty() => v,
_ => env::var("CARGO_PKG_VERSION").expect("cargo always sets CARGO_PKG_VERSION"),
};
println!("cargo:rustc-env=COURSEBANK_VERSION={version}");
println!("cargo:rerun-if-env-changed=COURSEBANK_VERSION");
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
}