This repository was archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (38 loc) · 1.33 KB
/
Makefile
File metadata and controls
52 lines (38 loc) · 1.33 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
46
47
48
49
50
51
52
VERSION=$(shell git describe --always | sed 's|v\(.*\)|\1|')
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
OS:=$(shell uname -s | awk '{ print tolower($$1) }')
ORGANIZATION=timescale
ARCH=$(shell go env GOARCH)
ifeq ($(ARCH),)
ARCH=amd64
endif
ifeq ($(shell uname -m), i386)
ARCH=386
endif
# Packages for running tests
PKGS:= $(shell go list ./... | grep -v /vendor)
SOURCES:=$(shell find . -name '*.go' | grep -v './vendor')
TARGET:=prometheus-postgresql-adapter
.PHONY: all clean build docker-image docker-push test
all: $(TARGET) version.properties
version.properties:
@echo "version=${VERSION}" > version.properties
.target_os:
@echo $(OS) > .target_os
build: $(TARGET)
$(TARGET): .target_os $(SOURCES)
GOOS=$(OS) GOARCH=${ARCH} CGO_ENABLED=0 go build -a --ldflags '-w' -o $@ ./cmd/$@
docker-image: version.properties
docker build -t $(ORGANIZATION)/$(TARGET):latest .
docker tag $(ORGANIZATION)/$(TARGET):latest $(ORGANIZATION)/$(TARGET):${VERSION}
docker tag $(ORGANIZATION)/$(TARGET):latest $(ORGANIZATION)/$(TARGET):${BRANCH}
docker-push: docker-image
docker push $(ORGANIZATION)/$(TARGET):latest
docker push $(ORGANIZATION)/$(TARGET):${VERSION}
docker push $(ORGANIZATION)/$(TARGET):${BRANCH}
test:
go clean -testcache $(PKGS)
go test -v -race $(PKGS)
clean:
go clean $(PKGS)
rm -f *~ $(TARGET) version.properties .target_os