From 041b2dd29d30a8ecadca22ef25282cbad672d94e Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Fri, 18 Sep 2026 09:56:10 +0200 Subject: Show tui and server versions in the status line; derive version from git - build: VERSION defaults to git describe, deploy passes the tag via --build-arg - bokftui: srv version from meta, right-aligned next to the status line --- Dockerfile | 3 ++- Makefile | 3 ++- clients/bokftui.c | 16 ++++++++++++++++ scripts/deploy.sh | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c22b19..d658d70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ # syntax=docker/dockerfile:1 FROM debian:bookworm-slim AS build +ARG VERSION=0.1.0-dev RUN apt-get update \ && apt-get install -y --no-install-recommends build-essential libncurses-dev \ libssl-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /src COPY . . -RUN make -j"$(nproc)" && make test +RUN make -j"$(nproc)" VERSION="$VERSION" && make test VERSION="$VERSION" FROM debian:bookworm-slim AS runtime RUN apt-get update \ diff --git a/Makefile b/Makefile index 6912473..418dc8e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CC ?= cc CFLAGS ?= -O2 -g -VERSION = 0.1.0-dev +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null \ + || echo 0.1.0-dev) WARN = -Wall -Wextra -Wshadow -Wstrict-prototypes -Wmissing-prototypes \ -Wpointer-arith -Wvla -Wformat=2 diff --git a/clients/bokftui.c b/clients/bokftui.c index 5daa606..a7bbf7c 100644 --- a/clients/bokftui.c +++ b/clients/bokftui.c @@ -134,6 +134,9 @@ static int jbool_val(const char *resp, const char *path, int def) /* ------------------------------------------------------------------ */ static char g_status[512]; +static char g_server_version[32]; + +static int disp_width(const char *s); static void show_error(const char *title, const char *resp); static int64_t vouchers_new(struct app *a); @@ -415,6 +418,15 @@ static void frame(const char *title) if (g_status[0]) { attron(A_DIM); mvaddnstr(1, 2, g_status, COLS - 4); + char ver[96]; + if (g_server_version[0]) + snprintf(ver, sizeof ver, "tui %s srv %s", BOKF_VERSION, + g_server_version); + else + snprintf(ver, sizeof ver, "tui %s", BOKF_VERSION); + int x = COLS - 3 - disp_width(ver); + if (x > disp_width(g_status) + 6) + mvaddstr(1, x, ver); attroff(A_DIM); } } @@ -956,6 +968,10 @@ static void app_refresh_context(struct app *a) a->max_attachment_bytes = 10 * 1024 * 1024; resp = client_rpc(&a->conn, "meta", NULL, 0, NULL); if (resp && client_ok(resp)) { + char *ver = jstr_dup(resp, "result.version"); + if (ver && *ver) + snprintf(g_server_version, sizeof g_server_version, "%s", ver); + free(ver); int64_t v = jint_val(resp, "result.limits.max_attachment_bytes", 0); if (v > 0) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 2abd1e1..25c86dc 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -60,7 +60,7 @@ esac if [ "$BOKF_BUILD" = local ]; then echo "deploy: building image bokf:$TAG locally" - docker build -t "bokf:$TAG" . + docker build --build-arg "VERSION=$TAG" -t "bokf:$TAG" . echo "deploy: shipping image to $BOKF_HOST" docker save "bokf:$TAG" | gzip | "${SSH[@]}" 'gunzip | docker load' else @@ -69,7 +69,7 @@ else --exclude=./.git --exclude=./build --exclude=./var --exclude=./.env \ --exclude='./*.se' --exclude='./*.db' --exclude='./*.db-wal' \ --exclude='./*.db-shm' --exclude=./docs . | - "${SSH[@]}" "docker build -t 'bokf:$TAG' -" + "${SSH[@]}" "docker build --build-arg 'VERSION=$TAG' -t 'bokf:$TAG' -" fi remote "mkdir -p '$BOKF_REMOTE_DIR'" -- cgit v1.3