The commit that runs: in the footer and at /version
CI / secret scan (push) Successful in 5s
CI / fmt, clippy, tests (push) Successful in 24s

Every page's footer names the commit the binary is built from, with a link
to it on the forge, and /version answers with the full hash, open without a
login like /healthz, so a script can tell which release is live.

build.rs writes COMMIT: from VISA_COMMIT, which the flake sets to its
source's revision (a Nix build has no .git), else from git in a checkout,
else empty. The flake sets it on the package alone, not on the
dependencies' build, which so stays cached from commit to commit.
This commit is contained in:
grabowski committed 2026-11-18 14:41:16 +07:00
1 parent a2cedcdd7e
commit 17426dba12
9 files changed
+140 -4

No files matched your search

+21 -1
View File
@@ -311,6 +311,7 @@ pub fn router(st: Arc<AppState>) -> Router {
.route("/logout", post(auth::logout))
.route("/signed-out", get(auth::signed_out))
.route("/healthz", get(healthz))
.route("/version", get(version))
.route("/static/{*path}", get(static_file))
// asked for by pages without their own icon: an image or a PDF
.route(
@@ -328,7 +329,7 @@ pub fn router(st: Arc<AppState>) -> Router {
fn is_public(path: &str) -> bool {
matches!(
path,
"/healthz" | "/login" | "/auth/callback" | "/signed-out" | "/favicon.ico"
"/healthz" | "/version" | "/login" | "/auth/callback" | "/signed-out" | "/favicon.ico"
) || path.starts_with("/static/")
}
@@ -569,6 +570,8 @@ pub fn page(
csrf => &user.csrf,
v => embedded::STATIC_HASH,
version => VERSION,
commit => embedded::short(embedded::COMMIT),
commit_url => embedded::url(embedded::COMMIT),
..ctx
};
render(st, name, full, status)
@@ -623,6 +626,23 @@ async fn healthz(State(st): State<Arc<AppState>>) -> Response {
}
}
/// The commit that runs, in full, for scripts and the fleet's checks; open
/// without a session, like the health check.
async fn version() -> Response {
let commit = match embedded::COMMIT {
"" => "unknown",
c => c,
};
(
[
(header::CONTENT_TYPE, "text/plain; charset=utf-8"),
(header::CACHE_CONTROL, "no-store"),
],
format!("{commit}\n"),
)
.into_response()
}
async fn static_file(Path(path): Path<String>) -> Response {
match embedded::static_file(&path) {
Some(bytes) => (