mark/Makefile

47 lines
966 B
Makefile
Raw Normal View History

2019-03-26 14:42:26 +03:00
NAME = $(notdir $(PWD))
VERSION = $(shell printf "%s.%s" \
$$(git rev-list --count HEAD) \
$$(git rev-parse --short HEAD) \
)
GO111MODULE = on
2019-03-26 14:42:26 +03:00
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REMOTE = kovetskiy
version:
@echo $(VERSION)
get:
go get -v -d
build:
@echo :: building go binary $(VERSION)
CGO_ENABLED=0 go build \
2019-03-26 14:42:26 +03:00
-ldflags "-X main.version=$(VERSION)" \
-gcflags "-trimpath $(GOPATH)/src"
image:
@echo :: building image $(NAME):$(VERSION)
@docker build -t $(NAME):$(VERSION) -f Dockerfile .
docker tag $(NAME):$(VERSION) $(NAME):latest
push:
$(if $(REMOTE),,$(error REMOTE is not set))
$(eval VERSION ?= latest)
$(eval TAG ?= $(REMOTE)/$(NAME):$(VERSION))
@echo :: pushing image $(TAG)
@docker tag $(NAME):$(VERSION) $(TAG)
@docker push $(TAG)
2019-03-26 14:55:38 +03:00
@docker tag $(NAME):$(VERSION) $(REMOTE)/$(NAME):latest
2019-03-26 14:42:26 +03:00
@docker push $(REMOTE)/$(NAME):latest
2020-04-16 14:18:05 +03:00
release: image push
git tag -f $(VERSION)
git push --tags
2019-03-26 14:42:26 +03:00
clean:
rm -rf $(NAME)