From cb36beaf2e0639baa86dc60b7b615f64c5d069f8 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Sat, 14 Feb 2026 18:58:59 +0000 Subject: [PATCH] build: add VERSION-based release workflow Introduce VERSION as the app version source of truth and add make bump-patch to increment VERSION, commit, and create a matching vX.Y.Z tag. Wire VERSION into build outputs by injecting it into webterm.Version for make build-go and Docker image builds, and include VERSION in Docker build context. Also remove the visible dashboard container count subtitle while keeping count updates in browser console logs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .dockerignore | 1 + Dockerfile | 3 ++- Makefile | 20 ++++++++++++++++++-- README.md | 4 +++- VERSION | 1 + go/webterm/constants.go | 19 ++++++++++++++++++- go/webterm/server.go | 2 +- 7 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 VERSION diff --git a/.dockerignore b/.dockerignore index 757b526..d8d8af1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ !go/** !Dockerfile !.dockerignore +!VERSION diff --git a/Dockerfile b/Dockerfile index 1bdc0a8..72d4d65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,8 @@ WORKDIR /src COPY go/go.mod go/go.sum ./go/ RUN cd go && go mod download COPY go ./go -RUN cd go && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/webterm ./cmd/webterm +COPY VERSION ./VERSION +RUN cd go && VERSION=$(cat /src/VERSION) && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/rcarmo/webterm-go-port/webterm.Version=$VERSION" -o /out/webterm ./cmd/webterm FROM alpine:3.21 AS runtime diff --git a/Makefile b/Makefile index d5515f9..c61bad6 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ -.PHONY: help install install-dev lint format test race coverage check fuzz build-go build build-fast bundle bundle-watch bundle-clean clean clean-all build-all typecheck +.PHONY: help install install-dev lint format test race coverage check fuzz build-go build build-fast bundle bundle-watch bundle-clean clean clean-all build-all typecheck bump-patch GO_DIR = go STATIC_JS_DIR = go/webterm/static/js TERMINAL_TS = $(STATIC_JS_DIR)/terminal.ts TERMINAL_JS = $(STATIC_JS_DIR)/terminal.js GHOSTTY_WASM = $(STATIC_JS_DIR)/ghostty-vt.wasm +VERSION_FILE = VERSION +VERSION = $(shell test -f $(VERSION_FILE) && cat $(VERSION_FILE) || echo dev) +GO_VERSION_LDFLAGS = -X github.com/rcarmo/webterm-go-port/webterm.Version=$(VERSION) help: ## Show this help @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' @@ -55,7 +58,7 @@ bundle-watch: node_modules ## Watch mode for frontend development bun run watch build-go: ## Build Go CLI binary - cd $(GO_DIR) && mkdir -p bin && go build -o ./bin/webterm ./cmd/webterm + cd $(GO_DIR) && mkdir -p bin && go build -ldflags "$(GO_VERSION_LDFLAGS)" -o ./bin/webterm ./cmd/webterm clean: ## Remove coverage artifacts rm -f $(GO_DIR)/coverage.out @@ -67,3 +70,16 @@ clean-all: clean bundle-clean ## Remove all generated artifacts build-all: clean-all install-dev build check build-go ## Full reproducible build from scratch @echo "Build complete!" + +bump-patch: ## Bump patch version in VERSION and create git tag + @if [ ! -f $(VERSION_FILE) ]; then echo "VERSION file not found"; exit 1; fi + @OLD=$$(cat $(VERSION_FILE)); \ + MAJOR=$$(echo $$OLD | cut -d. -f1); \ + MINOR=$$(echo $$OLD | cut -d. -f2); \ + PATCH=$$(echo $$OLD | cut -d. -f3); \ + NEW="$$MAJOR.$$MINOR.$$((PATCH + 1))"; \ + echo $$NEW > $(VERSION_FILE); \ + git add $(VERSION_FILE); \ + git commit -m "Bump version to $$NEW"; \ + git tag "v$$NEW"; \ + echo "Bumped version: $$OLD -> $$NEW (tagged v$$NEW)" diff --git a/README.md b/README.md index 9f8383e..7d0c6a2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Icon](docs/icon-256.png) -`webterm` serves terminal sessions over HTTP/WebSocket, with a dashboard mode for multiple sessions and Docker-aware tiles. +`webterm` serves terminal sessions over HTTP/WebSocket, with a dashboard mode for multiple sessions and live-updating terminal tiles. This repository is the Go port of the original Python implementation, which is preserved in the `python` branch. @@ -10,6 +10,7 @@ This repository is the Go port of the original Python implementation, which is p ## Features +- Typeahead find for quickly finding and launching sessions with minimal friction - Web terminal with reconnect support - Ghostty WebAssembly terminal engine for fast rendering - Session dashboard with live SVG screenshots @@ -101,6 +102,7 @@ make install-dev make check make race make test +make bump-patch ``` Frontend bundle tasks: diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..f0bb29e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.3.0 diff --git a/go/webterm/constants.go b/go/webterm/constants.go index 93d4146..2955caf 100644 --- a/go/webterm/constants.go +++ b/go/webterm/constants.go @@ -7,7 +7,6 @@ import ( ) const ( - Version = "1.3.0" DefaultHost = "0.0.0.0" DefaultPort = 8080 DefaultTheme = "xterm" @@ -23,8 +22,26 @@ const ( AutoCommandSentinel = "__docker_exec__" ) +var Version = "dev" + var Windows = runtime.GOOS == "windows" +func init() { + if strings.TrimSpace(Version) != "" && Version != "dev" { + return + } + for _, candidate := range []string{"VERSION", "../VERSION", "../../VERSION"} { + data, err := os.ReadFile(candidate) + if err != nil { + continue + } + if v := strings.TrimSpace(string(data)); v != "" { + Version = v + return + } + } +} + func EnvBool(name string) bool { v, ok := os.LookupEnv(name) if !ok { diff --git a/go/webterm/server.go b/go/webterm/server.go index bd0920d..e68564f 100644 --- a/go/webterm/server.go +++ b/go/webterm/server.go @@ -755,7 +755,7 @@ func (s *LocalServer) handleRoot(w http.ResponseWriter, r *http.Request) { if s.dockerWatch { dockerWatchJS = "true" } - html := fmt.Sprintf(`Session Dashboard

Sessions

`, string(tilesJSON), composeModeJS, dockerWatchJS) + html := fmt.Sprintf(`Session Dashboard

Sessions

`, string(tilesJSON), composeModeJS, dockerWatchJS) w.Header().Set("Content-Type", "text/html") _, _ = io.WriteString(w, html) return