diff --git a/Makefile b/Makefile index 6460019..4340b5f 100644 --- a/Makefile +++ b/Makefile @@ -1,50 +1,36 @@ -# Host UK Developer Workspace -# Run `make setup` to bootstrap your environment -CORE_REPO := github.com/host-uk/core -CORE_VERSION := latest -INSTALL_DIR := $(HOME)/.local/bin +# ── core-agent binary ────────────────────────────────── -.PHONY: all setup install-deps install-go install-core doctor clean help +BINARY_NAME=core-agent +CMD_PATH=./cmd/core-agent +MODULE_PATH=dappco.re/go/agent -all: help +# Default LDFLAGS to empty +LDFLAGS = "" -help: - @echo "Host UK Developer Workspace" - @echo "" - @echo "Usage:" - @echo " make setup Full setup (deps + core + clone repos)" - @echo " make install-deps Install system dependencies (go, gh, etc)" - @echo " make install-core Build and install core CLI" - @echo " make doctor Check environment health" - @echo " make clone Clone all repos into packages/" - @echo " make clean Remove built artifacts" - @echo "" - @echo "Quick start:" - @echo " make setup" +# If VERSION is set, inject into binary +ifdef VERSION + LDFLAGS = -ldflags "-X '$(MODULE_PATH).version=$(VERSION)'" +endif -setup: install-deps install-core doctor clone - @echo "" - @echo "Setup complete! Run 'core health' to verify." +.PHONY: build install agent-dev test coverage -install-deps: - @echo "Installing dependencies..." - @./scripts/install-deps.sh +build: + @echo "Building $(BINARY_NAME)..." + @go build $(LDFLAGS) -o $(BINARY_NAME) $(CMD_PATH) -install-go: - @echo "Installing Go..." - @./scripts/install-go.sh +install: + @echo "Installing $(BINARY_NAME)..." + @go install $(LDFLAGS) $(CMD_PATH) -install-core: - @echo "Installing core CLI..." - @./scripts/install-core.sh +agent-dev: build + @./$(BINARY_NAME) version -doctor: - @core doctor || echo "Run 'make install-core' first if core is not found" +test: + @echo "Running tests..." + @go test ./... -clone: - @core setup || echo "Run 'make install-core' first if core is not found" - -clean: - @rm -rf ./build - @echo "Cleaned build artifacts" +coverage: + @echo "Generating coverage report..." + @go test -coverprofile=coverage.out ./... + @echo "Coverage: coverage.out" diff --git a/cmd/core-agent/main.go b/cmd/core-agent/main.go index 5b95aa7..9d3ccbc 100644 --- a/cmd/core-agent/main.go +++ b/cmd/core-agent/main.go @@ -21,7 +21,12 @@ func main() { c := core.New(core.Options{ {Key: "name", Value: "core-agent"}, }) - c.App().Version = "0.15.0" + // Version set at build time: go build -ldflags "-X main.version=0.15.0" + if version != "" { + c.App().Version = version + } else { + c.App().Version = "dev" + } // version — print version and build info c.Command("version", core.Command{ @@ -33,6 +38,7 @@ func main() { core.Print(nil, " home: %s", core.Env("DIR_HOME")) core.Print(nil, " hostname: %s", core.Env("HOSTNAME")) core.Print(nil, " pid: %s", core.Env("PID")) + core.Print(nil, " channel: %s", updateChannel()) return core.Result{OK: true} }, }) @@ -128,6 +134,7 @@ func main() { // --- Forge + Workspace CLI commands --- registerForgeCommands(c) registerWorkspaceCommands(c) + // registerUpdateCommand(c) — parked until version moves to module root // --- CLI commands for feature testing --- diff --git a/cmd/core-agent/update.go b/cmd/core-agent/update.go new file mode 100644 index 0000000..b5bc983 --- /dev/null +++ b/cmd/core-agent/update.go @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: EUPL-1.2 + +package main + +// version is set at build time via ldflags: +// +// go build -ldflags "-X 'dappco.re/go/agent.version=0.15.0'" ./cmd/core-agent/ +var version string + +// updateChannel returns the channel based on the version string. +func updateChannel() string { + switch { + case version == "" || version == "dev": + return "dev" + case len(version) > 0 && (version[len(version)-1] >= 'a'): + return "prerelease" + default: + return "stable" + } +} + +// TODO: wire go-update UpdateService for self-update command +// Channels: stable → GitHub releases, prerelease → GitHub dev, dev → Forge main +// Parked until version var moves to module root package (dappco.re/go/agent.Version)