2022-08-01 06:22:17 +03:00
|
|
|
-include environ.inc
|
|
|
|
.PHONY: help deps dev build install image release test clean clean-all
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
export CGO_ENABLED=0
|
|
|
|
VERSION=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "0.0.0")
|
|
|
|
COMMIT=$(shell git rev-parse --short HEAD || echo "HEAD")
|
|
|
|
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
GOCMD=go
|
|
|
|
GOVER=$(shell go version | grep -o -E 'go1\.17\.[0-9]+')
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
DESTDIR=/usr/local/bin
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
ifeq ($(BRANCH), master)
|
|
|
|
IMAGE := prologic/tube
|
|
|
|
TAG := latest
|
|
|
|
else
|
|
|
|
IMAGE := prologic/tube
|
|
|
|
TAG := dev
|
|
|
|
endif
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
all: help
|
2020-03-21 02:55:06 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
.PHONY: help
|
|
|
|
|
|
|
|
help: ## Show this help message
|
|
|
|
@echo "tube - a Youtube-like (without censorship and features you don't need!) Video Sharing App"
|
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
preflight: ## Run preflight checks to ensure you have the right build tools
|
|
|
|
@./preflight.sh
|
|
|
|
|
|
|
|
deps: ## Install any dependencies required
|
|
|
|
|
|
|
|
dev : DEBUG=1
|
|
|
|
dev : server ## Build debug version of tube
|
|
|
|
@./tube
|
|
|
|
|
|
|
|
server: generate ## Build the tube server
|
2022-08-01 07:28:03 +03:00
|
|
|
@$(GOCMD) build -tags "embed static_build" \
|
2022-08-01 06:22:17 +03:00
|
|
|
-ldflags "-w \
|
|
|
|
-X $(shell go list).Version=$(VERSION) \
|
|
|
|
-X $(shell go list).Commit=$(COMMIT)" \
|
2020-03-21 01:20:16 +03:00
|
|
|
.
|
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
build: server ## Build the server
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
generate: ## Genereate any code required by the build
|
|
|
|
@if [ x"$(DEBUG)" = x"1" ]; then \
|
|
|
|
echo 'Running in debug mode...'; \
|
|
|
|
fi
|
2020-03-30 11:23:18 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
install: build ## Install tube to $DESTDIR
|
|
|
|
@install -D -m 755 tube $(DESTDIR)/tube
|
2020-03-21 01:20:16 +03:00
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
ifeq ($(PUBLISH), 1)
|
|
|
|
image: generate ## Build the Docker image
|
2022-08-01 07:03:00 +03:00
|
|
|
@docker buildx build --push --platform linux/arm64,linux/amd64 --tag $(IMAGE):$(TAG) --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" .
|
2022-08-01 06:22:17 +03:00
|
|
|
else
|
|
|
|
image: generate
|
2022-08-01 07:03:00 +03:00
|
|
|
@docker buildx build --platform linux/arm64,linux/amd64 --tag $(IMAGE):$(TAG) --build-arg VERSION="$(VERSION)" --build-arg COMMIT="$(COMMIT)" .
|
2022-08-01 06:22:17 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
release: generate ## Release a new version to Gitea
|
2020-03-21 01:20:16 +03:00
|
|
|
@./tools/release.sh
|
|
|
|
|
2022-08-01 06:22:17 +03:00
|
|
|
fmt: ## Format sources fiels
|
|
|
|
@$(GOCMD) fmt ./...
|
|
|
|
|
|
|
|
test: ## Run test suite
|
|
|
|
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race ./...
|
|
|
|
|
|
|
|
coverage: ## Get test coverage report
|
|
|
|
@CGO_ENABLED=1 $(GOCMD) test -v -cover -race -cover -coverprofile=coverage.out ./...
|
|
|
|
@$(GOCMD) tool cover -html=coverage.out
|
|
|
|
|
|
|
|
clean: ## Remove untracked files
|
|
|
|
@git clean -f -d -x
|
|
|
|
|
|
|
|
clean-all: ## Remove untracked and Git ignores files
|
2020-03-21 01:20:16 +03:00
|
|
|
@git clean -f -d -X
|