summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile53
1 files changed, 43 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 931f4e7..8cdf2fd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,48 @@
1.PHONY: clean deps tests 1.PHONY: clean rebuild update-deps tests help docker docker-tests docker-publish
2 2
3all: php-malware-finder/phpmalwarefinder 3NAME := php-malware-finder
4TAG_COMMIT := $(shell git rev-list --abbrev-commit --all --max-count=1)
5VERSION := $(shell git describe --abbrev=0 --tags --exact-match $(TAG_COMMIT) 2>/dev/null || true)
6IMAGE_VERSION := $(VERSION)
7DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d%H%M")
8ifeq ($(VERSION),)
9 VERSION := $(DATE)
10 IMAGE_VERSION := latest
11endif
12LDFLAGS := "-X main.version=$(VERSION)"
13GO_FLAGS := -o $(NAME) -ldflags $(LDFLAGS)
14IMAGE_REGISTRY := ghcr.io
15IMAGE_REGISTRY_USER := jvoisin
16IMAGE_NAME := $(IMAGE_REGISTRY)/$(IMAGE_REGISTRY_USER)/$(NAME)
4 17
5php-malware-finder/phpmalwarefinder: 18all: php-malware-finder
6 go build -o php-malware-finder/phpmalwarefinder php-malware-finder/phpmalwarefinder.go
7 19
8clean: 20php-malware-finder: ## Build application
9 rm -f php-malware-finder/phpmalwarefinder 21 @go build $(GO_FLAGS) .
10 22
11deps: 23clean: ## Delete build artifacts
12 go mod tidy -v 24 @rm -f $(NAME)
13 25
14tests: php-malware-finder/phpmalwarefinder 26rebuild: clean all ## Delete build artifacts and rebuild
15 @cd ./php-malware-finder && bash ./tests.sh 27
28update-deps: ## Update dependencies
29 @go get -u .
30 @go mod tidy -v
31
32tests: php-malware-finder ## Run test suite
33 @bash ./tests.sh
34
35docker: ## Build docker image
36 docker pull $(IMAGE_NAME):latest || true
37 docker build --pull -t $(IMAGE_NAME):latest .
38 docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_VERSION)
39
40docker-tests: ## Run docker image against the samples folder
41 @docker run --rm -v $(shell pwd)/data/samples:/data $(IMAGE_NAME):latest
42
43docker-publish: ## Push docker image to the container registry
44 @docker push $(IMAGE_NAME):latest
45 @(test "$(IMAGE_VERSION)" != "latest" && docker push $(IMAGE_NAME):$(IMAGE_VERSION)) || true
46
47help: ## Show this help
48 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'