-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
27 lines (18 loc) · 886 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
INFO = github.com/mmbros/quotes/cmd
VERSION := $(shell git tag | grep ^v | sort -V | tail -n 1)
# GOXVER := $(shell go version | awk '{print $$3}')
GOXVER := $(shell go version)
GITCOMMIT := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date '+%F %T %z')
OSARCH := $(shell uname -s -m)
TIMESTAMP := $(shell date +%Y%m%dT%H%M%S)
# go build -v -ldflags="-X 'main.Version=v1.0.0' -X 'app/build.User=$(id -u -n)' -X 'app/build.Time=$(date)'"
COMMON_LDFLAGS = -X '${INFO}.BuildTime=${BUILDTIME}' -X '${INFO}.GitCommit=${GITCOMMIT}' -X '${INFO}.GoVersion=${GOXVER}' -X '${INFO}.OsArch=${OSARCH}'
PROD_LDFLAGS = -ldflags "-X '${INFO}.Version=${VERSION}' ${COMMON_LDFLAGS}"
DEV_LDFLAGS = -ldflags "-X '${INFO}.Version=dev-${TIMESTAMP}' ${COMMON_LDFLAGS}"
BIN=./bin/quotes
all: prod
dev:
go build ${DEV_LDFLAGS} -o ${BIN} *.go
prod:
go build ${PROD_LDFLAGS} -o ${BIN} *.go