-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
34 lines (28 loc) · 900 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
.PHONY: help test build deploy run clean
GO_FLAGS ?=
NAME := fan2go
OUTPUT_BIN ?= bin/${NAME}
PACKAGE := github.com/markusressel/$(NAME)
GIT_REV ?= $(shell git rev-parse --short HEAD)
SOURCE_DATE_EPOCH ?= $(shell date +%s)
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
VERSION ?= 0.9.0
test: ## Run all tests
@go clean --testcache && go test -v ./...
build: ## Builds the CLI
@go build ${GO_FLAGS} \
-ldflags "-w -s \
-X ${NAME}/cmd/global.Version=${VERSION} \
-X ${PACKAGE}/cmd/global.Version=${VERSION} \
-X ${NAME}/cmd/global.Commit=${GIT_REV} \
-X ${PACKAGE}/cmd/global.Commit=${GIT_REV} \
-X ${NAME}/cmd/global.Date=${DATE} \
-X ${PACKAGE}/cmd/global.Date=${DATE}" \
-a -tags netgo -o ${OUTPUT_BIN} main.go
run: build
./${OUTPUT_BIN}
deploy: build
sudo cp "${OUTPUT_BIN}" "/usr/bin/${NAME}"
clean:
go clean
rm ${OUTPUT_BIN}