-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (42 loc) · 1.25 KB
/
Makefile
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
VERSION := v0.3.0
REPOSITORY := getupcloud
IMAGE_NAME := azure-devops-agent
GIT_COMMIT := $(shell git log -n1 --oneline)
GIT_COMMIT_ID := $(shell git log -n 1 --pretty=format:%h)
BUILD_DATE := $(shell LC_ALL=C date -u)
.PHONY: default
default: image
.PHONY: release
release: DOCKER_NO_CACHE:=--no-cache
release: check-dirty image tag-latest push push-latest tag-git push-git
.PHONY: image
image:
docker build . -t $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) $(DOCKER_NO_CACHE) \
--build-arg VERSION="$(VERSION)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
--build-arg GIT_COMMIT_ID="$(GIT_COMMIT_ID)"
check-dirty: DIFF_STATUS := $(shell git diff --stat)
check-dirty:
@if [ -n "$(DIFF_STATUS)" ]; then \
echo "--> Refusing to build release on a dirty tree"; \
echo "--> Commit and try again."; \
exit 2; \
fi
.PHONY: push
push:
docker push $(REPOSITORY)/$(IMAGE_NAME):$(VERSION)
.PHONY: tag-latest
tag-latest:
docker tag $(REPOSITORY)/$(IMAGE_NAME):$(VERSION) $(REPOSITORY)/$(IMAGE_NAME):latest
.PHONY: push-latest
push-latest:
docker push $(REPOSITORY)/$(IMAGE_NAME):latest
.PHONY: tag-git
tag-git:
git pull --tags
git tag $(VERSION)
.PHONY: push-git
push-git:
git push --tags
git push