forked from paychex/prometheus-emcecs-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (33 loc) · 1.17 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
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TARGET_BINARY := prometheus-emcecs-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)
GOPROXY?=https://proxy.golang.org
all: clean build
goreleaser_hook: clean goreleaser_pre
build:
GOPROXY=${GOPROXY} 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
# This is needed to make goreleaser work in Travis
# Since cross compiling requires special modules for Windows
# we need to run the commands for both Windows and Linux
goreleaser_pre:
GOPROXY=${GOPROXY} GOOS=linux GOARCH=amd64 go mod download
GOPROXY=${GOPROXY} GOOS=windows GOARCH=amd64 go mod download
GOPROXY=${GOPROXY} GOOS=linux GOARCH=amd64 go get ./...
GOPROXY=${GOPROXY} 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