From 4c20b1ed6d617d2dffbd167f2b15d4bcdfb9f492 Mon Sep 17 00:00:00 2001 From: Drew Smirnoff Date: Wed, 17 Jun 2026 13:41:59 +0400 Subject: [PATCH] chore: add make install (#1482) ## What? Add `make install` that overrides the current matcha install with the newly built ## Why? Adds an option for people to clone the repo and install a freshly built, instead of downloading binaries, and developers to use the latest version for day-to-day testing. Signed-off-by: drew --- Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 600e962fc7abf1b87547b34701a9b9d300b74684..bffae37074ebf2dc8b8892991b2ae24e84ca700a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: build test run run-log clean lint fmt vet build-full generate_screenshots +.PHONY: build test run run-log clean lint fmt vet build-full install generate_screenshots + +INSTALL_DIR ?= /usr/local/bin BINARY_NAME=matcha BUILD_DIR=bin @@ -23,6 +25,20 @@ generate_screenshots: build: go build -o $(BUILD_DIR)/$(BINARY_NAME) . +install: + @echo "Building and installing $(BINARY_NAME)..." + @EXISTING=$$(which $(BINARY_NAME) 2>/dev/null); \ + DEST=$$([ -n "$$EXISTING" ] && dirname "$$EXISTING" || echo "$(INSTALL_DIR)"); \ + VERSION=$$([ -n "$(VERSION)" ] && echo "$(VERSION)" || git describe --tags --abbrev=0 2>/dev/null || echo "dev"); \ + COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ + DATE=$$(date +%Y-%m-%d); \ + echo "Version: $$VERSION"; \ + echo "Commit: $$COMMIT"; \ + echo "Date: $$DATE"; \ + go build -ldflags="-X 'main.version=$$VERSION' -X 'main.commit=$$COMMIT' -X 'main.date=$$DATE'" -o $(BUILD_DIR)/$(BINARY_NAME) .; \ + install -m 755 $(BUILD_DIR)/$(BINARY_NAME) "$$DEST/$(BINARY_NAME)"; \ + echo "Installed to $$DEST/$(BINARY_NAME)" + build-full: @echo "Building with version information..." @VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "dev"); \