From 947533a2792f724c59047f0f26d27009b734a144 Mon Sep 17 00:00:00 2001 From: MDietermann Date: Tue, 14 Apr 2026 21:16:25 +0200 Subject: [PATCH] build: add Makefile with release, snapshot, completions targets --- Makefile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e96e886 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +.PHONY: build snapshot release completions clean help + +GO ?= go +BIN := archduino + +help: ## Show this help + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-14s %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +build: ## Local dev build into ./archduino + $(GO) build -o $(BIN) ./cmd/archduino + +completions: ## Regenerate shell completions into completions/ + @mkdir -p completions + $(GO) run ./cmd/archduino completion bash > completions/archduino.bash + $(GO) run ./cmd/archduino completion zsh > completions/_archduino + $(GO) run ./cmd/archduino completion fish > completions/archduino.fish + +snapshot: ## Local goreleaser dry run into dist/ + goreleaser release --snapshot --clean + +clean: ## Remove build artifacts + rm -rf dist/ completions/ $(BIN) + +release: ## Compute next SemVer from commits, tag, and push + @command -v svu >/dev/null || { echo "svu not found. Run: go install github.com/caarlos0/svu@latest"; exit 1; } + @test -z "$$(git status --porcelain)" || { echo "working tree is dirty; commit or stash first"; exit 1; } + @branch=$$(git rev-parse --abbrev-ref HEAD); \ + if [ "$$branch" != "master" ]; then echo "must be on master (currently on $$branch)"; exit 1; fi + @current=$$(svu current 2>/dev/null || echo "none"); \ + next=$$(svu next); \ + echo "Current: $$current"; \ + echo "Next: $$next"; \ + echo; \ + echo "Commits since $$current:"; \ + if [ "$$current" = "none" ]; then git log --oneline; else git log --oneline $$current..HEAD; fi; \ + echo; \ + printf "Tag %s and push? [y/N] " "$$next"; read ans; \ + if [ "$$ans" != "y" ] && [ "$$ans" != "Y" ]; then echo "aborted"; exit 1; fi; \ + git tag "$$next" && git push origin "$$next"