This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
vault-sidekick/Makefile

97 lines
2.4 KiB
Makefile
Raw Permalink Normal View History

2015-09-18 05:14:15 -04:00
NAME=vault-sidekick
AUTHOR ?= ukhomeofficedigital
REGISTRY ?= quay.io
GOVERSION ?= 1.8.1
2015-09-18 05:14:15 -04:00
HARDWARE=$(shell uname -m)
VERSION ?= $(shell awk '/release =/ { print $$3 }' main.go | sed 's/"//g')
GIT_SHA=$(shell git --no-pager describe --always --dirty)
LFLAGS ?= -X main.gitsha=${GIT_SHA}
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
2015-09-18 05:14:15 -04:00
.PHONY: test authors changelog build docker static release
2015-09-18 05:14:15 -04:00
default: build
build: deps
@echo "--> Compiling the project"
mkdir -p bin
godep go build -ldflags '-w ${LFLAGS}' -o bin/${NAME}
2015-09-18 05:14:15 -04:00
static: deps
@echo "--> Compiling the static binary"
mkdir -p bin
CGO_ENABLED=0 GOOS=linux godep go build -a -tags netgo -ldflags '-w ${LFLAGS}' -o bin/${NAME}
docker-build:
@echo "--> Compiling the project"
${SUDO} docker run --rm \
-v ${PWD}:/go/src/github.com/UKHomeOffice/${NAME} \
-w /go/src/github.com/UKHomeOffice/${NAME} \
-e GOOS=linux \
golang:${GOVERSION} \
make static
docker: static
@echo "--> Building the docker image"
docker build -t ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION} .
docker-release:
@echo "--> Building a release image"
@make static
@make docker
@docker push ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION}
push: docker
@echo "--> Pushing the image to docker.io"
docker push ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION}
release: static
mkdir -p release
gzip -c bin/${NAME} > release/${NAME}_${VERSION}_linux_${HARDWARE}.gz
rm -f release/${NAME}
clean:
rm -rf ./bin 2>/dev/null
rm -rf ./release 2>/dev/null
2015-09-18 05:14:15 -04:00
authors:
@echo "--> Updating the AUTHORS"
2015-09-18 05:14:15 -04:00
git log --format='%aN <%aE>' | sort -u > AUTHORS
deps:
@echo "--> Installing build dependencies"
@go get github.com/tools/godep
vet:
@echo "--> Running go tool vet $(VETARGS) ."
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
go get golang.org/x/tools/cmd/vet; \
fi
@go tool vet $(VETARGS) .
format:
@echo "--> Running go fmt"
@go fmt $(PACKAGES)
2016-10-01 18:18:21 -04:00
gofmt:
@echo "--> Running gofmt check"
@gofmt -s -l *.go \
| grep -q \.go ; if [ $$? -eq 0 ]; then \
echo "You need to runn the make format, we have file unformatted"; \
gofmt -s -l *.go; \
exit 1; \
fi
cover:
@echo "--> Running go cover"
2016-10-01 18:18:21 -04:00
@godep go test --cover
test: deps
@echo "--> Running the tests"
2015-09-18 05:14:15 -04:00
go test -v
2016-10-01 18:18:21 -04:00
@$(MAKE) gofmt
@$(MAKE) vet
2015-09-18 05:14:15 -04:00
changelog: release
git log $(shell git tag | tail -n1)..HEAD --no-merges --format=%B > changelog