forked from codacy/git-version
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (38 loc) · 1.6 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
CRYSTAL?=$(shell which crystal)
CRYSTAL_FLAGS=--release
CRYSTAL_STATIC_FLAGS=--static --no-debug
VERSION?=$(shell ./bin/git-version)
all: fmt test build docker_build ## clean and produce target binary and docker image
.PHONY: test
test: ## runs crystal tests
$(CRYSTAL) spec spec/*.cr
.PHONY: fmt
fmt: ## format the crystal sources
$(CRYSTAL) tool format
build: ## compiles from crystal sources
mkdir -p bin
$(CRYSTAL) build $(CRYSTAL_FLAGS) src/main.cr -o bin/git-version
.PHONY: buildStatic
buildStatic: ## compiles from crystal sources into static binary
mkdir -p bin
docker run --rm -it -v $(PWD):/app -w /app durosoft/crystal-alpine:latest crystal build $(CRYSTAL_FLAGS) $(CRYSTAL_STATIC_FLAGS) src/main.cr -o bin/git-version
.PHONY: docker
docker: build docker_build ## compiles from sources and produce the docker image
docker_build: ## build the docker image
docker build -t dunghd/git-version:${VERSION} .
.PHONY: clean
clean: ## clean target directories
rm -rf bin
.PHONY: push-docker-image
push-docker-image: ## push the docker image to the registry (DOCKER_USER and DOCKER_PASS mandatory)
docker push dunghd/git-version:${VERSION}
.PHONY: push-latest-docker-image
push-latest-docker-image: ## push the docker image with the "latest" tag to the registry (DOCKER_USER and DOCKER_PASS mandatory)
docker tag dunghd/git-version:${VERSION} dunghd/git-version:latest &&\
docker push dunghd/git-version:latest
.PHONY: help
help:
@echo "make help"
@echo "\n"
@grep -E '^[a-zA-Z_/%\-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo "\n"