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

View File

@@ -10,9 +10,10 @@ COPY . .
RUN go tool templ generate 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}') && \
VERSION=$(git describe --tags --always) && \ VERSION=$(git describe --tags --always) && \
COMMIT=$(git rev-parse --short HEAD) && \ COMMIT=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 go build -ldflags="-s -X github.com/ryanhamamura/games/version.Version=$VERSION -X github.com/ryanhamamura/games/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
FROM scratch FROM scratch