56feed0dab
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
46 lines
945 B
Makefile
46 lines
945 B
Makefile
.PHONY:
|
|
|
|
VERSION := $(shell git describe --tags || git rev-parse --short HEAD)
|
|
DEPLOY_ACCOUNT := "appleboy"
|
|
DEPLOY_IMAGE := "drone-telegram"
|
|
|
|
ifneq ($(shell uname), Darwin)
|
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
|
else
|
|
EXTLDFLAGS =
|
|
endif
|
|
|
|
install:
|
|
glide install
|
|
|
|
build:
|
|
go build -ldflags="$(EXTLDFLAGS)-s -w -X main.Version=$(VERSION)"
|
|
|
|
test:
|
|
go test -v -coverprofile=coverage.txt
|
|
|
|
html:
|
|
go tool cover -html=coverage.txt
|
|
|
|
update:
|
|
glide up
|
|
|
|
docker_build:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags="-X main.Version=$(VERSION)"
|
|
|
|
docker_image:
|
|
docker build --rm -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) .
|
|
|
|
docker: docker_build docker_image
|
|
|
|
docker_deploy:
|
|
ifeq ($(tag),)
|
|
@echo "Usage: make $@ tag=<tag>"
|
|
@exit 1
|
|
endif
|
|
docker tag $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):latest $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
|
docker push $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
|
|
|
clean:
|
|
rm -rf coverage.txt ${DEPLOY_IMAGE}
|