1 Commits

Author SHA1 Message Date
Ryan Hamamura
66dbcfc751 feat: display app version in UI footer
Some checks failed
CI / Deploy / test (pull_request) Successful in 15s
CI / Deploy / lint (pull_request) Failing after 2s
CI / Deploy / deploy (pull_request) Has been skipped
- Add version package with build-time variables
- Inject version via ldflags in Dockerfile using git describe
- Show version in footer on every page
- Log version and commit on server startup
2026-03-03 09:37:24 -10:00
3 changed files with 5 additions and 16 deletions

View File

@@ -48,8 +48,6 @@ jobs:
runs-on: games runs-on: games
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for git describe
- name: Sync to deploy directory - name: Sync to deploy directory
run: | run: |
@@ -61,8 +59,4 @@ jobs:
mkdir -p $DEPLOY_DIR/data mkdir -p $DEPLOY_DIR/data
- name: Rebuild and restart - name: Rebuild and restart
run: | run: cd $DEPLOY_DIR && docker compose up -d --build --remove-orphans
cd $DEPLOY_DIR
VERSION=$(git describe --tags --always)
COMMIT=$(git rev-parse --short HEAD)
VERSION=$VERSION COMMIT=$COMMIT docker compose up -d --build --remove-orphans

View File

@@ -1,9 +1,6 @@
FROM docker.io/golang:1.25.4-alpine AS build FROM docker.io/golang:1.25.4-alpine AS build
ARG VERSION=dev RUN apk add --no-cache upx git
ARG COMMIT=unknown
RUN apk add --no-cache upx
WORKDIR /src WORKDIR /src
COPY go.mod go.sum ./ COPY go.mod go.sum ./
@@ -14,6 +11,8 @@ RUN go tool templ generate
RUN go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify RUN go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
RUN --mount=type=cache,target=/root/.cache/go-build \ RUN --mount=type=cache,target=/root/.cache/go-build \
MODULE=$(head -1 go.mod | awk '{print $2}') && \ MODULE=$(head -1 go.mod | awk '{print $2}') && \
VERSION=$(git describe --tags --always) && \
COMMIT=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 go build -ldflags="-s -X $MODULE/version.Version=$VERSION -X $MODULE/version.Commit=$COMMIT" -o /bin/games . CGO_ENABLED=0 go build -ldflags="-s -X $MODULE/version.Version=$VERSION -X $MODULE/version.Commit=$COMMIT" -o /bin/games .
RUN upx -9 -k /bin/games RUN upx -9 -k /bin/games

View File

@@ -1,10 +1,6 @@
services: services:
games: games:
build: build: .
context: .
args:
VERSION: ${VERSION:-dev}
COMMIT: ${COMMIT:-unknown}
container_name: games container_name: games
restart: unless-stopped restart: unless-stopped
ports: ports: