-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (38 loc) · 1.35 KB
/
Makefile
File metadata and controls
45 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export PATH := $(abspath ./vendor/bin):$(PATH)
BASE_PACKAGE_NAME = github.com/counterapi/counter
GIT_VERSION = $(shell git describe --tags --always 2> /dev/null || echo 0.0.0)
LDFLAGS = -ldflags "-X $(BASE_PACKAGE_NAME)/pkg/info.Version=$(GIT_VERSION)"
BUFFER := $(shell mktemp)
REPORT_DIR = dist/report
COVER_PROFILE = $(REPORT_DIR)/coverage.out
.PHONY: build
build:
CGO_ENABLED=0 go build $(LDFLAGS) -installsuffix cgo -o dist/counter main.go
build-for-container:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -a -installsuffix cgo -o dist/counter-linux main.go
.PHONY: lint
lint:
@echo "Checking code style"
gofmt -l . | tee $(BUFFER)
@! test -s $(BUFFER)
go vet ./...
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1
@golangci-lint --version
golangci-lint run
.PHONY: test
test:
@echo "Running unit tests"
mkdir -p $(REPORT_DIR)
go test -covermode=count -coverprofile=$(COVER_PROFILE) -tags test -failfast ./...
go tool cover -html=$(COVER_PROFILE) -o $(REPORT_DIR)/coverage.html
.PHONY: cut-tag
cut-tag:
@echo "Cutting $(version)"
git tag $(version)
git push origin $(version)
.PHONY: release
release: build-for-container
@echo "Releasing $(GIT_VERSION)"
docker build -t counter .
docker tag counter:latest counterapi/counter:$(GIT_VERSION)
docker push counterapi/counter:$(GIT_VERSION)