-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
34 lines (29 loc) · 899 Bytes
/
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
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TARGET_BINARY := prometheus-isilon-exporter
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
RELEASE?=$(shell git describe --abbrev=4 --dirty --always --tags)
COMMIT?=$(shell git rev-parse --short HEAD)
all: clean build
goreleaser_hook: clean goreleaser_pre
build:
GO111MODULE=on go build -o bin/${TARGET_BINARY} \
-ldflags="-X main.commit=${COMMIT} \
-X main.date=${BUILD_TIME} \
-X main.version=${RELEASE}" \
./cmd
goreleaser:
goreleaser --snapshot --skip-publish --rm-dist
goreleaser_pre:
GOOS=linux GOARCH=amd64 go mod download
GOOS=windows GOARCH=amd64 go mod download
GOOS=linux GOARCH=amd64 go get ./...
GOOS=windows GOARCH=amd64 go get ./...
clean:
for file in bin/$(TARGET_BINARY); do \
if [ -e "$$file" ]; then \
rm -f "$$file" || exit 1; \
fi \
done
if [ -e "./dist" ]; then \
rm -rf ./dist; \
fi