forked from codacy/git-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (39 loc) · 1.68 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
CRYSTAL?=$(shell which crystal)
CRYSTAL_FLAGS=--release
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/entrypoint/git-version.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 src/env2props.cr -o bin/env2props --release --static --no-debug
.PHONY: docker
docker: build docker_build ## compiles from sources and produce the docker image
docker_build: ## build the docker image
docker build -t codacy/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 login -u $(DOCKER_USER) -p $(DOCKER_PASS) &&\
docker push codacy/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 login -u $(DOCKER_USER) -p $(DOCKER_PASS) &&\
docker tag codacy/git-version:${VERSION} codacy/git-version:latest &&\
docker push codacy/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"