2014-11-24 15:45:48 +00:00
|
|
|
|
|
|
|
# Adds build information from git repo
|
|
|
|
#
|
|
|
|
# as suggested by tatsushid in
|
|
|
|
# https://github.com/spf13/hugo/issues/540
|
|
|
|
|
|
|
|
COMMIT_HASH=`git rev-parse --short HEAD 2>/dev/null`
|
|
|
|
BUILD_DATE=`date +%FT%T%z`
|
2015-08-20 20:48:42 +00:00
|
|
|
LDFLAGS=-ldflags "-X github.com/spf13/hugo/hugolib.CommitHash=${COMMIT_HASH} -X github.com/spf13/hugo/hugolib.BuildDate=${BUILD_DATE}"
|
2014-11-24 15:45:48 +00:00
|
|
|
|
|
|
|
all: gitinfo
|
|
|
|
|
2014-12-09 02:54:49 +00:00
|
|
|
install: install-gitinfo
|
|
|
|
|
2014-11-24 15:45:48 +00:00
|
|
|
help:
|
|
|
|
echo ${COMMIT_HASH}
|
|
|
|
echo ${BUILD_DATE}
|
|
|
|
|
|
|
|
gitinfo:
|
|
|
|
go build ${LDFLAGS} -o hugo main.go
|
|
|
|
|
2014-12-09 02:54:49 +00:00
|
|
|
install-gitinfo:
|
|
|
|
go install ${LDFLAGS} ./...
|
|
|
|
|
2014-11-24 15:45:48 +00:00
|
|
|
no-git-info:
|
|
|
|
go build -o hugo main.go
|
|
|
|
|
2016-01-04 07:27:21 +00:00
|
|
|
docker:
|
|
|
|
docker build -t hugo .
|
|
|
|
docker rm -f hugo-build || true
|
|
|
|
docker run --name hugo-build hugo ls /go/bin
|
|
|
|
docker cp hugo-build:/go/bin/hugo .
|
|
|
|
docker rm hugo-build
|