Makefile 705 B

123456789101112131415161718192021222324252627282930313233343536
  1. GOCMD ?= go
  2. GOBUILD = $(GOCMD) build
  3. GOCLEAN = $(GOCMD) clean
  4. GOTEST = $(GOCMD) test
  5. GOGET = $(GOCMD) get
  6. BINARY_NAME = livego
  7. BINARY_UNIX = $(BINARY_NAME)_unix
  8. DOCKER_ACC ?= gwuhaolin
  9. DOCKER_REPO ?= livego
  10. TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null)
  11. default: all
  12. all: test build dockerize
  13. build:
  14. $(GOBUILD) -o $(BINARY_NAME) -v -ldflags="-X main.VERSION=$(TAG)"
  15. test:
  16. $(GOTEST) -v ./...
  17. clean:
  18. $(GOCLEAN)
  19. rm -f $(BINARY_NAME)
  20. rm -f $(BINARY_UNIX)
  21. run: build
  22. ./$(BINARY_NAME)
  23. build-linux:
  24. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
  25. dockerize:
  26. docker build -t $(DOCKER_ACC)/$(DOCKER_REPO):$(TAG) .
  27. docker push $(DOCKER_ACC)/$(DOCKER_REPO):$(TAG)