historyposter/Makefile

65 lines
1.3 KiB
Makefile
Raw Permalink Normal View History

2020-09-21 20:04:20 +00:00
VERSION := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
BUILDUSER := $(shell whoami)
BUILDHOST := $(shell hostname -s)
BUILDARCH := $(shell uname -m)
FN := historyposter
UNAME_S := $(shell uname -s)
GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
# osx can't statically link apparently?!
ifeq ($(UNAME_S),Darwin)
GOFLAGS := -ldflags "$(GOLDFLAGS)"
endif
ifneq ($(UNAME_S),Darwin)
GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
endif
2020-09-21 21:11:18 +00:00
default: debug
commit: fmt lint
git commit -a
2020-09-21 20:04:20 +00:00
fmt:
2020-09-21 21:11:18 +00:00
#go fmt ./...
2020-09-21 20:04:20 +00:00
goimports -l -w .
2020-09-21 21:11:18 +00:00
golangci-lint run --fix
lint:
golangci-lint run
sh -c 'test -z "$$(gofmt -l .)"'
2020-09-21 20:04:20 +00:00
debug: build
2020-09-22 14:52:58 +00:00
-mkdir -p ./.env.d
echo 1 > ./.env.d/HISTORYPOSTER_DEBUG
GOTRACEBACK=all envdir ./.env.d ./$(FN)d 2>&1 | tee -a debug.log
2020-09-21 20:04:20 +00:00
debugger:
cd cmd/historyposter && dlv debug main.go
2020-09-21 20:04:20 +00:00
run: build
2020-09-22 08:27:47 +00:00
./$(FN)d
2020-09-21 20:04:20 +00:00
clean:
2020-09-22 14:49:46 +00:00
-rm ./$(FN)d debug.log
2020-09-21 20:04:20 +00:00
2020-09-22 08:27:47 +00:00
build: ./$(FN)d
2020-09-21 20:04:20 +00:00
docker:
docker build .
go-get:
cd cmd/$(FN) && go get -v
2020-09-22 08:27:47 +00:00
./$(FN)d: */*.go cmd/*/*.go go-get
cd cmd/$(FN) && go build -o ../../$(FN)d $(GOFLAGS) .
2020-09-21 20:04:20 +00:00
.PHONY: build fmt test is_uncommitted docker dist hub upload-docker-image clean run rundebug default build-docker-image-dist