Add /version endpoint and GitHub Actions release workflow

This commit is contained in:
Ganonmaster
2026-03-18 13:42:40 +00:00
parent 33acab96a2
commit abc6cf1ecd
5 changed files with 119 additions and 0 deletions
+1
View File
@@ -54,6 +54,7 @@ async fn main() {
let app = Router::new()
.route("/", get(routes::emotes::root))
.route("/version", get(routes::version::version))
.route("/json", get(routes::emotes::list_emotes))
.route("/emotes", post(routes::emotes::create_emote))
.route("/emotes/{uuid}", put(routes::emotes::update_emote))
+1
View File
@@ -1 +1,2 @@
pub mod emotes;
pub mod version;
+25
View File
@@ -0,0 +1,25 @@
use axum::response::{IntoResponse, Json};
use serde_json::json;
/// GET /version
/// Returns the current git commit hash and tag (if present).
pub async fn version() -> impl IntoResponse {
let commit = env!("GIT_COMMIT_HASH");
let tag = env!("GIT_TAG");
// `git describe --tags --exact-match` sets an exact semver-like tag when the
// commit is tagged; otherwise the build script stores "untagged".
let response = if tag == "untagged" {
json!({
"commit": commit,
"version": null
})
} else {
json!({
"commit": commit,
"version": tag
})
};
Json(response)
}