fix(build): make install now properly builds, signs, and installs to ~/.local/bin

Previously `make install` used `go install` which put the binary in ~/go/bin
without codesigning, while PATH used ~/.local/bin - causing chronic stale
binary issues. Now install depends on build (which codesigns on macOS) and
copies to the correct location.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Executed-By: mayor
Role: mayor
This commit is contained in:
mayor
2026-01-25 13:55:02 -08:00
committed by gastown/crew/joe
parent ca51980ffc
commit 20271a9a71

View File

@@ -5,10 +5,18 @@
# Default target
all: build
BINARY := bd
BUILD_DIR := .
INSTALL_DIR := $(HOME)/.local/bin
# Build the bd binary
build:
@echo "Building bd..."
go build -ldflags="-X main.Build=$$(git rev-parse --short HEAD)" -o bd ./cmd/bd
go build -ldflags="-X main.Build=$$(git rev-parse --short HEAD)" -o $(BUILD_DIR)/$(BINARY) ./cmd/bd
ifeq ($(shell uname),Darwin)
@codesign -s - -f $(BUILD_DIR)/$(BINARY) 2>/dev/null || true
@echo "Signed $(BINARY) for macOS"
endif
# Run all tests (skips known broken tests listed in .test-skip)
test:
@@ -33,12 +41,12 @@ bench-quick:
@echo "Running quick performance benchmarks..."
go test -bench=. -benchtime=100ms -tags=bench -run=^$$ ./internal/storage/sqlite/ -timeout=15m
# Install bd to GOPATH/bin
install:
@echo "Installing bd to $$(go env GOPATH)/bin..."
@bash -c 'commit=$$(git rev-parse HEAD 2>/dev/null || echo ""); \
branch=$$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo ""); \
go install -ldflags="-X main.Commit=$$commit -X main.Branch=$$branch" ./cmd/bd'
# Install bd to ~/.local/bin (builds, signs on macOS, and copies)
install: build
@mkdir -p $(INSTALL_DIR)
@rm -f $(INSTALL_DIR)/$(BINARY)
@cp $(BUILD_DIR)/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@echo "Installed $(BINARY) to $(INSTALL_DIR)/$(BINARY)"
# Clean build artifacts and benchmark profiles
clean:
@@ -54,6 +62,6 @@ help:
@echo " make test - Run all tests"
@echo " make bench - Run performance benchmarks (generates CPU profiles)"
@echo " make bench-quick - Run quick benchmarks (shorter benchtime)"
@echo " make install - Install bd to GOPATH/bin"
@echo " make install - Install bd to ~/.local/bin (with codesign on macOS)"
@echo " make clean - Remove build artifacts and profile files"
@echo " make help - Show this help message"