2023-03-11 23:13:53 -05:00
|
|
|
-include environ.inc
|
|
|
|
.PHONY: help deps dev build install image release test clean
|
|
|
|
|
|
|
|
export CGO_ENABLED=0
|
|
|
|
VERSION=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION")
|
|
|
|
COMMIT=$(shell git rev-parse --short HEAD || echo "$COMMIT")
|
|
|
|
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
BUILD=$(shell git show -s --pretty=format:%cI)
|
|
|
|
GOCMD=go
|
|
|
|
|
2023-03-12 01:34:38 -05:00
|
|
|
DESTDIR ?= $(GOBIN)
|
2023-03-11 23:13:53 -05:00
|
|
|
|
|
|
|
ifeq ($(LOCAL), 1)
|
|
|
|
IMAGE := r.mills.io/prologic/zs
|
|
|
|
TAG := dev
|
|
|
|
else
|
|
|
|
IMAGE := prologic/zs
|
|
|
|
TAG := latest
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: help
|
|
|
|
|
|
|
|
help: ## Show this help message
|
|
|
|
@echo "zs - Zen Static site generator"
|
|
|
|
@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 required dependencies
|
|
|
|
|
|
|
|
dev : DEBUG=1
|
|
|
|
dev : build ## Build debug version of zs (cli)
|
|
|
|
@./zs -v
|
|
|
|
|
|
|
|
cli: ## Build the zs command-line tool
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
@echo "Building in debug mode..."
|
|
|
|
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
|
|
|
|
-ldflags "\
|
2023-03-25 23:49:09 -04:00
|
|
|
-X main.Version=$(VERSION) \
|
|
|
|
-X main.Commit=$(COMMIT) \
|
|
|
|
-X main.Build=$(BUILD)" \
|
2023-03-11 23:13:53 -05:00
|
|
|
.
|
|
|
|
else
|
|
|
|
@$(GOCMD) build -tags "netgo static_build" -installsuffix netgo \
|
|
|
|
-ldflags "-w \
|
2023-03-25 23:49:09 -04:00
|
|
|
-X main.Version=$(VERSION) \
|
|
|
|
-X main.Commit=$(COMMIT) \
|
|
|
|
-X main.Build=$(BUILD)" \
|
2023-03-11 23:13:53 -05:00
|
|
|
.
|
|
|
|
endif
|
|
|
|
|
|
|
|
build: cli ## Build the cli
|
|
|
|
|
|
|
|
install: build ## Install zs (cli) to $DESTDIR
|
|
|
|
@install -D -m 755 zs $(DESTDIR)/zs
|
|
|
|
|
|
|
|
ifeq ($(PUBLISH), 1)
|
2023-03-12 08:12:12 -04:00
|
|
|
image: ## Build the Docker image
|
2023-03-11 23:13:53 -05:00
|
|
|
@docker buildx build \
|
|
|
|
--build-arg VERSION="$(VERSION)" \
|
|
|
|
--build-arg COMMIT="$(COMMIT)" \
|
|
|
|
--build-arg BUILD="$(BUILD)" \
|
|
|
|
--platform linux/amd64,linux/arm64 --push -t $(IMAGE):$(TAG) .
|
|
|
|
else
|
2023-03-12 08:12:12 -04:00
|
|
|
image:
|
2023-03-11 23:13:53 -05:00
|
|
|
@docker build \
|
|
|
|
--build-arg VERSION="$(VERSION)" \
|
|
|
|
--build-arg COMMIT="$(COMMIT)" \
|
|
|
|
--build-arg BUILD="$(BUILD)" \
|
|
|
|
-t $(IMAGE):$(TAG) .
|
|
|
|
endif
|
|
|
|
|
2023-03-12 08:12:12 -04:00
|
|
|
release: ## Release a new version to Gitea
|
2023-03-11 23:13:53 -05:00
|
|
|
@./tools/release.sh
|
|
|
|
|
|
|
|
fmt: ## Format sources files
|
|
|
|
@$(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 ignored files
|
|
|
|
@git clean -f -d -X
|