-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
64 lines (54 loc) · 1.41 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
SHELL := /bin/bash
VERSION_PACKAGE = github.com/replicatedhq/pvmigrate/pkg/version
VERSION ?=`git describe --tags --dirty`
DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
CURRENT_USER := $(shell id -u -n)
GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifneq "$(GIT_TREE)" ""
define GIT_UPDATE_INDEX_CMD
git update-index --assume-unchanged
endef
define GIT_SHA
`git rev-parse HEAD`
endef
else
define GIT_UPDATE_INDEX_CMD
echo "Not a git repo, skipping git update-index"
endef
define GIT_SHA
""
endef
endif
define LDFLAGS
-ldflags "\
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
.PHONY: clean
clean:
rm -rf ./bin
.PHONY: deps
deps:
@if [ -z `which golangci-lint` ]; then \
echo "installing golangci-lint";\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin;\
fi
.PHONY: lint
lint: deps
golangci-lint run --timeout=5m ./...
.PHONY: vet
vet:
go vet ./... ./cmd/...
.PHONY: test
test: lint vet
go test ./... ./cmd/...
.PHONY: build
build: bin/pvmigrate
bin/pvmigrate: cmd/main.go pkg/migrate/migrate.go pkg/version/version.go
go build ${LDFLAGS} -o bin/pvmigrate cmd/main.go
.PHONY: ttl-sh
ttl-sh:
docker build --pull -f testing/Dockerfile -t ttl.sh/${CURRENT_USER}/pvmigrate:${VERSION} .
docker push ttl.sh/${CURRENT_USER}/pvmigrate:${VERSION}