2019-09-30 08:26:19 +00:00
|
|
|
IMAGE_REPO=infracloudio/botkube
|
2019-03-05 13:49:27 +00:00
|
|
|
TAG=$(shell cut -d'=' -f2- .release)
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := build
|
2019-08-26 07:09:32 +00:00
|
|
|
.PHONY: release git-tag check-git-status build container-image pre-build tag-image publish test system-check
|
2019-03-05 13:49:27 +00:00
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Show this help.
|
|
|
|
help:
|
|
|
|
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{print substr($$1,1,index($$1,":")),c}1{c=0}' $(MAKEFILE_LIST) | column -s: -t
|
|
|
|
|
|
|
|
# Docker Tasks
|
|
|
|
# Make a release
|
2019-08-26 07:09:32 +00:00
|
|
|
release: check-git-status test container-image tag-image publish git-tag
|
2019-08-08 11:52:52 +00:00
|
|
|
@echo "Successfully releeased version $(TAG)"
|
2019-03-05 13:49:27 +00:00
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Create a git tag
|
2019-03-05 13:49:27 +00:00
|
|
|
git-tag:
|
|
|
|
@echo "Creating a git tag"
|
2019-06-07 13:53:30 +00:00
|
|
|
@git add .release helm/botkube deploy-all-in-one.yaml deploy-all-in-one-tls.yaml CHANGELOG.md
|
|
|
|
@git commit -m "Release $(TAG)" ;
|
2019-03-05 13:49:27 +00:00
|
|
|
@git tag $(TAG) ;
|
2019-06-07 13:53:30 +00:00
|
|
|
@git push --tags origin develop;
|
2019-03-05 13:49:27 +00:00
|
|
|
@echo 'Git tag pushed successfully' ;
|
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Check git status
|
2019-03-05 13:49:27 +00:00
|
|
|
check-git-status:
|
|
|
|
@echo "Checking git status"
|
2019-06-07 13:53:30 +00:00
|
|
|
@if [ -n "$(shell git tag | grep $(TAG))" ] ; then echo 'ERROR: Tag already exists' && exit 1 ; fi
|
|
|
|
@if [ -z "$(shell git remote -v)" ] ; then echo 'ERROR: No remote to push tags to' && exit 1 ; fi
|
|
|
|
@if [ -z "$(shell git config user.email)" ] ; then echo 'ERROR: Unable to detect git credentials' && exit 1 ; fi
|
2019-03-05 13:49:27 +00:00
|
|
|
|
2019-08-26 07:09:32 +00:00
|
|
|
# test
|
|
|
|
test: system-check
|
|
|
|
@echo "Starting unit and integration tests"
|
|
|
|
@./hack/runtests.sh
|
2019-08-08 11:52:52 +00:00
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Build the binary
|
2019-06-07 06:19:45 +00:00
|
|
|
build: pre-build
|
2020-10-05 04:23:36 +00:00
|
|
|
@cd cmd/botkube;GOOS_VAL=$(shell go env GOOS) GOARCH_VAL=$(shell go env GOARCH) go build -o $(shell go env GOPATH)/bin/botkube
|
2019-08-12 17:08:50 +00:00
|
|
|
@echo "Build completed successfully"
|
2020-10-05 04:23:36 +00:00
|
|
|
|
|
|
|
# Build the image
|
2019-08-08 11:52:52 +00:00
|
|
|
container-image: pre-build
|
2019-03-05 13:49:27 +00:00
|
|
|
@echo "Building docker image"
|
|
|
|
@docker build --build-arg GOOS_VAL=$(shell go env GOOS) --build-arg GOARCH_VAL=$(shell go env GOARCH) -t $(IMAGE_REPO) -f build/Dockerfile --no-cache .
|
|
|
|
@echo "Docker image build successfully"
|
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# system checks
|
2019-08-08 11:52:52 +00:00
|
|
|
system-check:
|
2019-03-05 13:49:27 +00:00
|
|
|
@echo "Checking system information"
|
2019-08-08 11:52:52 +00:00
|
|
|
@if [ -z "$(shell go env GOOS)" ] || [ -z "$(shell go env GOARCH)" ] ; \
|
|
|
|
then \
|
|
|
|
echo 'ERROR: Could not determine the system architecture.' && exit 1 ; \
|
|
|
|
else \
|
|
|
|
echo 'GOOS: $(shell go env GOOS)' ; \
|
|
|
|
echo 'GOARCH: $(shell go env GOARCH)' ; \
|
|
|
|
echo 'System information checks passed.'; \
|
|
|
|
fi ;
|
2019-03-05 13:49:27 +00:00
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Pre-build checks
|
2019-08-08 11:52:52 +00:00
|
|
|
pre-build: system-check
|
2019-03-05 13:49:27 +00:00
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Tag images
|
2019-08-08 11:52:52 +00:00
|
|
|
tag-image:
|
2019-03-05 13:49:27 +00:00
|
|
|
@echo 'Tagging image'
|
|
|
|
@docker tag $(IMAGE_REPO) $(IMAGE_REPO):$(TAG)
|
|
|
|
|
2020-10-05 04:23:36 +00:00
|
|
|
# Docker push image
|
2019-03-05 13:49:27 +00:00
|
|
|
publish:
|
|
|
|
@echo "Pushing docker image to repository"
|
|
|
|
@docker login
|
|
|
|
@docker push $(IMAGE_REPO):$(TAG)
|
2019-08-08 11:52:52 +00:00
|
|
|
@docker push $(IMAGE_REPO):latest
|
2020-10-05 04:23:36 +00:00
|
|
|
|
|
|
|
# Create KIND cluster
|
|
|
|
create-kind: system-check
|
|
|
|
@./hack/kind-cluster.sh create-kind
|
|
|
|
|
|
|
|
# Destroy KIND cluster
|
|
|
|
destroy-kind: system-check
|
|
|
|
@./hack/kind-cluster.sh destroy-kind
|
|
|
|
|