feat: add build-stamped version with --version flag and TUI header
Introduce tui.Version (defaults to "dev"), stamped at build time via a VERSION_LDFLAG in the Makefile (-X .../internal/tui.Version=$(VERSION)) across all build targets. main.go handles "--version"/"-v" before launching the TUI, and the version is shown next to the title in the header. Docs updated (README + CLAUDE). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -145,6 +145,14 @@ make push S3_BUCKET=<bucket> VERSION=<v> # sync dist/ to S3 (version + late
|
||||
make release S3_BUCKET=<bucket> VERSION=<v> # per-binary copy with OS/arch naming
|
||||
```
|
||||
|
||||
**Versioning:** `tui.Version` ([internal/tui/version.go](internal/tui/version.go))
|
||||
defaults to `"dev"` and is stamped at build time via `VERSION_LDFLAG`
|
||||
(`-X .../internal/tui.Version=$(VERSION)`) in the Makefile. `installer --version`
|
||||
(or `-v`) prints it and exits before the TUI starts; it is also shown in the TUI
|
||||
header. A plain `go build` leaves it as `"dev"`. The Makefile build rules have no
|
||||
source deps, so `make build` will not rebuild existing `dist/` artifacts — run
|
||||
`make clean` first when re-stamping a new VERSION.
|
||||
|
||||
Tests (`go test ./...`) cover the pure logic in
|
||||
[config_test.go](internal/tui/config_test.go) (config.toml/envs generation + numeric
|
||||
validation) and [form_test.go](internal/tui/form_test.go) (`FormStep.Values()`). The
|
||||
|
||||
@@ -1,33 +1,36 @@
|
||||
.PHONY: build clean push release help
|
||||
|
||||
VERSION ?= 1.0.0
|
||||
S3_BUCKET ?=
|
||||
S3_BUCKET ?=
|
||||
BINARY_NAME ?= installer
|
||||
BUILD_DIR := ./dist
|
||||
|
||||
MODULE := git.davinti.com.br/davinTI/app-dono/tui
|
||||
VERSION_LDFLAG := -X $(MODULE)/internal/tui.Version=$(VERSION)
|
||||
|
||||
ARCHS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
|
||||
|
||||
build: $(addprefix $(BUILD_DIR)/$(BINARY_NAME)-, $(subst /,-,$(ARCHS)))
|
||||
|
||||
$(BUILD_DIR)/$(BINARY_NAME)-linux-amd64:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-extldflags -static" -o $@ ./cmd
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-extldflags -static $(VERSION_LDFLAG)" -o $@ ./cmd
|
||||
|
||||
$(BUILD_DIR)/$(BINARY_NAME)-linux-arm64:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-extldflags -static" -o $@ ./cmd
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-extldflags -static $(VERSION_LDFLAG)" -o $@ ./cmd
|
||||
|
||||
$(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o $@ ./cmd
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$(VERSION_LDFLAG)" -o $@ ./cmd
|
||||
|
||||
$(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $@ ./cmd
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$(VERSION_LDFLAG)" -o $@ ./cmd
|
||||
|
||||
$(BUILD_DIR)/$(BINARY_NAME)-windows-amd64:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $@ ./cmd
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$(VERSION_LDFLAG)" -o $@ ./cmd
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
@@ -200,6 +200,15 @@ go build -o installer ./cmd
|
||||
./installer
|
||||
```
|
||||
|
||||
A versão é gravada no binário em tempo de build (`make build VERSION=1.2.0`) e pode ser
|
||||
consultada sem abrir a interface:
|
||||
|
||||
```bash
|
||||
./installer --version # ex.: app-dono installer 1.2.0
|
||||
```
|
||||
|
||||
Um `go build` simples (sem o `Makefile`) deixa a versão como `dev`.
|
||||
|
||||
## Documentação adicional
|
||||
|
||||
- [docs/fluxo.md](docs/fluxo.md) — detalhamento de cada etapa do assistente.
|
||||
|
||||
@@ -9,6 +9,14 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 {
|
||||
switch os.Args[1] {
|
||||
case "--version", "-v":
|
||||
fmt.Println("app-dono installer", tui.Version)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
p := tea.NewProgram(tui.InitialModel())
|
||||
if _, err := p.Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package tui
|
||||
|
||||
// Version is the installer version. It is stamped at build time via
|
||||
// -ldflags "-X git.davinti.com.br/davinTI/app-dono/tui/internal/tui.Version=<v>"
|
||||
// (see the Makefile) and defaults to "dev" for local builds.
|
||||
var Version = "dev"
|
||||
@@ -114,8 +114,10 @@ func (m Model) View() tea.View {
|
||||
|
||||
help := HelpStyle.Render(helpMsg)
|
||||
|
||||
title := TitleStyle.Render(header) + HelpStyle.Render(" v"+Version)
|
||||
|
||||
v := tea.NewView(fmt.Sprintf("\n%s%s\n\n%s\n\n%s%s\n",
|
||||
pad, TitleStyle.Render(header),
|
||||
pad, title,
|
||||
body,
|
||||
pad, help,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user