diff options
Diffstat (limited to 'GNUmakefile')
-rw-r--r-- | GNUmakefile | 81 |
1 files changed, 46 insertions, 35 deletions
diff --git a/GNUmakefile b/GNUmakefile index 28762ef..d2c51d9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,55 +1,66 @@ -SHELL := bash -.SHELLFLAGS := -eu -o pipefail -c -.ONESHELL: +.DEFAULT_GOAL := help .DELETE_ON_ERROR: -MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --warn-undefined-variables +.ONESHELL: +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c -CACHEDIR=/tmp/hugo-cache-$(USER) -DESTDIR=public/ -HOSTNAME=$(shell hostname -f) -REVISION=$(shell git rev-parse HEAD) +##### Variables ################################################################ +CACHEDIR := /tmp/hugo-cache-$(USER) +DESTDIR := public/ +HOSTNAME := $(shell hostname -f) +REVISION := $(shell git rev-parse HEAD) +##### Development ############################################################## .PHONY: build -build: ## make build # builds an optimized version of the website in $(DESTDIR) +build: ## make build + # TODO make sure to stash everything in content/ ? @echo "----- Generating site -----" - hugo --gc --minify --cleanDestinationDir -d $(DESTDIR) --cacheDir $(CACHEDIR) --buildFuture + hugo --gc --minify --cleanDestinationDir -d $(DESTDIR) \ + --cacheDir $(CACHEDIR) --buildFuture cp public/index.json search/ cp public/search/index.html search/ - (cd search && CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' ./search.go) - -.PHONY: buildah -buildah: ## make buildah # builds the container images - deploy/build-image.sh + cd search + CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' ./search.go .PHONY: clean -clean: ## make clean # removed all $(DESTDIR) contents +clean: ## make clean @echo "----- Cleaning old build -----" rm -f search/index.html search/index.json search/search rm -rf $(DESTDIR) +.PHONY: serve +serve: ## make serve # hugo web server development mode + hugo serve --disableFastRender --noHTTPCache \ + --cacheDir $(CACHEDIR) --bind 0.0.0.0 --port 1313 \ + -b http://$(HOSTNAME):1313/ --buildFuture --navigateToChanged + +##### Operations ############################################################### .PHONY: deploy -deploy: ## make deploy # deploy the website to myth.adyxax.org - rsync -a $(DESTDIR) root@myth.adyxax.org:/srv/www/ - rsync search/search root@myth.adyxax.org:/srv/www/search/search - ssh root@myth.adyxax.org "systemctl restart www-search" +deploy: ## make deploy + rsync -a $(DESTDIR) root@www.adyxax.org:/srv/www/ + rsync search/search root@www.adyxax.org:/usr/local/bin/www-search + ssh root@www.adyxax.org "systemctl restart www-search" -.PHONY: deploy-kube -deploy-kube: ## make deploy-kube # deploy the website to the active kubernetes context - sed -i deploy/www.yaml -e 's/^\(\s*image:[^:]*:\).*$$/\1$(REVISION)/' - kubectl apply -f deploy/www.yaml +##### Quality ################################################################## +.PHONY: check +check: ## run all code checks + (cd search && go mod verify && go vet ./...) -.PHONY: help -help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' +.PHONY: tidy +tidy: ## tidy up the code + (cd search && go fmt ./... && go mod tidy -v) -.PHONY: push -push: ## make push # push the built images to quay.io - buildah push adyxax/www quay.io/adyxax/www:$(REVISION) - buildah push adyxax/www-search quay.io/adyxax/www-search:$(REVISION) +##### Utils #################################################################### +.PHONY: confirm +confirm: + @echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ] -.PHONY: serve -serve: ## make serve # hugo web server development mode - hugo serve --disableFastRender --noHTTPCache --cacheDir $(CACHEDIR) --bind 0.0.0.0 --port 1313 -b http://$(HOSTNAME):1313/ --buildFuture --navigateToChanged +.PHONY: help +help: + @grep -E '^[a-zA-Z\/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | sort -.DEFAULT_GOAL := help +.PHONY: no-dirty +no-dirty: + git diff --exit-code |