1SHELL = /bin/bash
2.SHELLFLAGS = -o pipefail -c
3GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null)
4GIT_COMMIT := $(shell git rev-parse --short=9 HEAD)
5VERSION := $(if $(GIT_TAG),$(GIT_TAG),dev-$(GIT_COMMIT))
6
7.PHONY: help
8help: ## Print info about all commands
9 @echo "Commands:"
10 @echo
11 @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'
12
13.PHONY: build
14build: ## Build all executables
15 go build -ldflags "-X main.Version=$(VERSION)" -o photocopy ./cmd/photocopy
16 go build -o bodega ./cmd/bodega
17
18.PHONY: run
19run:
20 go build -ldflags "-X main.Version=dev-local" -o photocopy ./cmd/photocopy && ./photocopy run
21
22.PHONY: all
23all: build
24
25.PHONY: test
26test: ## Run tests
27 go clean -testcache && go test -v ./...
28
29.PHONY: lint
30lint: ## Verify code style and run static checks
31 go vet ./...
32 test -z $(gofmt -l ./...)
33
34.PHONY: fmt
35fmt: ## Run syntax re-formatting (modify in place)
36 go fmt ./...
37
38.PHONY: check
39check: ## Compile everything, checking syntax (does not output binaries)
40 go build ./...
41
42.env:
43 if [ ! -f ".env" ]; then cp example.dev.env .env; fi