-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
28 lines (23 loc) · 975 Bytes
/
Makefile
File metadata and controls
28 lines (23 loc) · 975 Bytes
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
.PHONY: docker-build on-tag publish
REGISTRY ?= docker.io
USERNAME ?= expelledboy
NAME = $(shell basename $(CURDIR))
IMAGE = $(REGISTRY)/$(USERNAME)/$(NAME)
help: ## Prints help for targets with comments
@cat $(MAKEFILE_LIST) \
| grep -E '^[a-zA-Z_-]+:.*?## .*$$' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
docker-build: ## Builds latest docker image
docker build --tag $(IMAGE):latest .
on-tag:
git describe --exact-match --tags $$(git log -n1 --pretty='%h') 1>/dev/null
publish: VERSION = $(shell git describe --always --tags | tr -d v)
publish: MINOR = $(shell echo $(VERSION) | sed -n 's/^\(.\..\).*/\1/p')
publish: on-tag docker-build ## Push docker image to $(REGISTRY)
docker tag $(IMAGE):latest $(IMAGE):$(VERSION)
docker tag $(IMAGE):latest $(IMAGE):$(MINOR)
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE):$(MINOR)
docker rmi $(IMAGE):$(VERSION)
docker rmi $(IMAGE):$(MINOR)
docker push $(IMAGE):latest