From 98f77073a1f9be0cd7a503aa2c922d7dc2ac3d69 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Thu, 27 Aug 2026 14:12:33 +0200 Subject: [PATCH] feat(agent): expose assembly version via GET /api/version (#171) --- src/Heimdall.Agent/Program.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Heimdall.Agent/Program.cs b/src/Heimdall.Agent/Program.cs index 34a61fe..bfa16c4 100644 --- a/src/Heimdall.Agent/Program.cs +++ b/src/Heimdall.Agent/Program.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Sentry.AspNetCore; using Heimdall.Agent; @@ -168,6 +169,25 @@ app.MapHealthChecks("/healthz", new HealthCheckOptions } }); +// ── Version endpoint — exposes assembly version for auto-update (ticket #100) ── +// Public (no auth): used by agents and external tooling for version checks. +app.MapGet("/api/version", () => +{ + var assembly = typeof(AgentOptions).Assembly; + var informational = assembly + .GetCustomAttribute()? + .InformationalVersion; + var version = assembly.GetName().Version?.ToString() ?? "0.0.0"; + + return Results.Ok(new + { + version = informational?.Split('+')[0] ?? version, + informational, + environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production", + timestamp = DateTime.UtcNow, + }); +}); + // ── Prometheus metrics endpoint (spec 13.1) ──────────────────────── app.MapPrometheusScrapingEndpoint("/metrics");