.PHONY: all build install test clean fmt lint help version bump-patch bump-minor bump-major release # Binary name BINARY_NAME=plcbundle INSTALL_PATH=$(GOPATH)/bin # Version information VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S') # Go commands GOCMD=go GOBUILD=$(GOCMD) build GOINSTALL=$(GOCMD) install GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test GOGET=$(GOCMD) get GOFMT=$(GOCMD) fmt GOMOD=$(GOCMD) mod # Build flags LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildDate=$(BUILD_DATE)" # Default target all: build # Build the CLI tool with version info build: @echo "Building $(BINARY_NAME) $(VERSION)..." $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/plcbundle # Install the CLI tool globally install: @echo "Installing $(BINARY_NAME) $(VERSION)..." $(GOINSTALL) $(LDFLAGS) ./cmd/plcbundle # Run tests test: @echo "Running tests..." $(GOTEST) -v ./... # Run tests with coverage test-coverage: @echo "Running tests with coverage..." $(GOTEST) -v -cover ./... # Clean build artifacts clean: @echo "Cleaning..." $(GOCLEAN) rm -f $(BINARY_NAME) # Format code fmt: @echo "Formatting code..." $(GOFMT) ./... # Download dependencies deps: @echo "Downloading dependencies..." $(GOMOD) download $(GOMOD) tidy # Verify dependencies verify: @echo "Verifying dependencies..." $(GOMOD) verify # Show current version version: @echo "Current version: $(VERSION)" @echo "Git commit: $(GIT_COMMIT)" @echo "Build date: $(BUILD_DATE)" # Bump patch version (0.1.0 -> 0.1.1) bump-patch: @echo "Bumping patch version..." @./scripts/bump-version.sh patch # Bump minor version (0.1.0 -> 0.2.0) bump-minor: @echo "Bumping minor version..." @./scripts/bump-version.sh minor # Bump major version (0.1.0 -> 1.0.0) bump-major: @echo "Bumping major version..." @./scripts/bump-version.sh major # Create a release (tags and pushes) release: @echo "Creating release for version $(VERSION)..." @./scripts/release.sh # Show help help: @echo "Available targets:" @echo " make build - Build the CLI tool" @echo " make install - Install CLI tool globally" @echo " make test - Run tests" @echo " make test-coverage - Run tests with coverage" @echo " make clean - Clean build artifacts" @echo " make fmt - Format code" @echo " make deps - Download dependencies" @echo " make verify - Verify dependencies" @echo " make version - Show current version" @echo " make bump-patch - Bump patch version (0.1.0 -> 0.1.1)" @echo " make bump-minor - Bump minor version (0.1.0 -> 0.2.0)" @echo " make bump-major - Bump major version (0.1.0 -> 1.0.0)" @echo " make release - Create and push release tag" @echo " make help - Show this help"