-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
30 lines (25 loc) · 1005 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
PACKAGE := $(shell git remote get-url --push origin | sed -E 's/.+[@|/](.+)\.(.+).git/\1.\2/' | sed 's/\:/\//')
APPLICATION := $(shell basename `pwd`)
BUILD_RFC3339 := $(shell date -u +"%Y-%m-%dT%H:%M:%S+00:00")
COMMIT := $(shell git rev-parse HEAD)
VERSION := $(shell git describe --tags)
GO_LDFLAGS := "-w -s \
-X github.com/jnovack/go-version.Package=${PACKAGE} \
-X github.com/jnovack/go-version.Application=${APPLICATION} \
-X github.com/jnovack/go-version.BuildDate=${BUILD_RFC3339} \
-X github.com/jnovack/go-version.Revision=${COMMIT} \
-X github.com/jnovack/go-version.Version=${VERSION} \
"
DOCKER_BUILD_ARGS := \
--build-arg PACKAGE=${PACKAGE} \
--build-arg APPLICATION=${APPLICATION} \
--build-arg BUILD_RFC3339=v${BUILD_RFC3339} \
--build-arg COMMIT=${COMMIT} \
--build-arg VERSION=${VERSION} \
--progress auto
all: build
.PHONY: build
build:
go build -o bin/${APPLICATION} -ldflags $(GO_LDFLAGS) cmd/*/*
docker:
docker build ${DOCKER_BUILD_ARGS} -t ${APPLICATION}:latest .