-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (86 loc) · 2.53 KB
/
Makefile
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
all: build
.PHONY: build
ifeq ($(GOPATH),)
PATH := $(HOME)/go/bin:$(PATH)
else
PATH := $(GOPATH)/bin:$(PATH)
endif
export GO111MODULE=on
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
REVSHORT = $(shell git rev-parse --short HEAD)
USER = $(shell whoami)
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
SHELL = /bin/sh
VERSION = $(shell git describe --tags --always)
ifneq ($(OS), Windows_NT)
CURRENT_PLATFORM = linux
ifeq ($(shell uname), Darwin)
SHELL := /bin/sh
CURRENT_PLATFORM = darwin
endif
else
CURRENT_PLATFORM = windows
endif
BUILD_VERSION = "\
-X github.com/johnmikee/cuebert/pkg/version.appName=${APP_NAME} \
-X github.com/johnmikee/cuebert/pkg/version.version=${VERSION} \
-X github.com/johnmikee/cuebert/pkg/version.branch=${BRANCH} \
-X github.com/johnmikee/cuebert/pkg/version.buildUser=${USER} \
-X github.com/johnmikee/cuebert/pkg/version.buildDate=${NOW} \
-X github.com/johnmikee/cuebert/pkg/version.revision=${REVISION} \
-X github.com/johnmikee/cuebert/pkg/version.goVersion=${GOVERSION}"
deps:
go mod download
test:
go test -cover ./...
build: cuebert
dev: .pre-build .pre-cuebert
go build -o build/$(CURRENT_PLATFORM)/cuebert -ldflags ${BUILD_VERSION} ./cuebert
clean:
rm -rf build/
rm -f *.zip
.pre-build:
mkdir -p build/darwin
mkdir -p build/linux
install-local: install-cuebert
APP_NAME = cuebert
.pre-cuebert:
$(eval APP_NAME = cuebert)
cuebert: .pre-build .pre-cuebert
go build -o build/$(CURRENT_PLATFORM)/cuebert -ldflags ${BUILD_VERSION} ./cuebert
install-cuebert: .pre-cuebert
go install -ldflags ${BUILD_VERSION} ./cmd/cuebert
xp-cuebert: .pre-build .pre-cuebert
GOOS=darwin go build -o build/darwin/cuebert -ldflags ${BUILD_VERSION} ./cuebert
GOOS=linux CGO_ENABLED=0 go build -o build/linux/cuebert -ldflags ${BUILD_VERSION} ./cuebert
release-zip: xp-cuebert
zip -r cue_${VERSION}.zip build/
docker-cuebert:
cp resources/Docker/cuebert/Dockerfile .
docker build -t cuebert --rm .
rm Dockerfile
run-docker-cuebert:
docker run cuebert cuebert -help
clean-postgres-db:
docker stop pgcue-db-container
@true
docker rm pgcue-db-container
@true
docker-postgres: clean-postgres-db
cp resources/Docker/postgres/Dockerfile .
docker build -t pgcue --rm .
rm Dockerfile
run-docker-postgres: docker-postgres
docker run -d --name pgcue-db-container -p 5432:5432 pgcue
static-check:
staticcheck ./...
vet:
go vet ./...
tidy:
go mod tidy
fmt:
gofumpt -l -w .
lint:
golangci-lint run -v -c .golangci.yml ./...