-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
35 lines (26 loc) · 915 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
35
OUTPUT_PATH=bin
BINARY=foto
VERSION=`git for-each-ref --sort=creatordate --format '%(refname)' refs/tags | tail -n 1 | sed 's/refs\/tags\/v\(.*\)/\1/g'`
BUILD_TIME=`date +%Y%m%d%H%M`
LDFLAGS=-ldflags "-X github.com/waynezhang/foto/internal/cmd.Version=${VERSION} -X github.com/waynezhang/foto/internal/cmd.Revision=${BUILD_TIME}"
all: build
build:
@go build ${LDFLAGS} -o ${OUTPUT_PATH}/${BINARY} main.go
test:
@go test ./...
coverage:
@TMPFILE=$$(mktemp); \
go test ./... -coverprofile=$$TMPFILE; \
go tool cover -html $$TMPFILE
changelog:
@TMP_FILE=$$(mktemp); \
cat CHANGELOG.md > $$TMP_FILE; \
go run github.com/release-lab/whatchanged/cmd/whatchanged@latest > CHANGELOG.md; \
echo "\n" >> CHANGELOG.md; \
cat $$TMP_FILE >> CHANGELOG.md
.PHONY: install
install:
@go install ${LDFLAGS} ./...
.PHONY: clean
clean:
@if [ -f ${OUTPUT_PATH}/${BINARY} ] ; then rm ${OUTPUT_PATH}/${BINARY} ; fi