task.mk/Makefile

68 lines
2.3 KiB
Makefile
Raw Normal View History

2023-01-20 12:35:52 -06:00
VERSION ?= $(shell git describe --tags --always --dirty=-dev)
2022-09-05 12:23:17 -05:00
TEMPLATES := $(shell find src/ -type f)
.DEFAULT_GOAL := help
msg = $(if $(tprint),$(call tprint,{a.bold}==> {a.magenta}$(1){a.end}),@echo '==> $(1)')
2022-09-05 12:23:17 -05:00
2023-01-19 12:54:57 -06:00
### task.mk development |> -d -ms b_green --align center
bootstrap: env hooks ## generate local dev environment |> -ms b_magenta -gs b_cyan
env: ##
2022-09-22 10:49:14 -05:00
$(call msg,Bootstrapping Environment)
@mamba create -p ./env python jinja2 black -y
@mamba run -p ./env pip install yartsu
hooks: ##
2022-09-07 15:48:46 -05:00
@git config core.hooksPath .githooks
docs-env: ##
2022-09-24 17:55:52 -05:00
@mamba run -p ./env pip install mkdocs-material mkdocs-git-revision-date-localized-plugin
2023-01-19 12:54:57 -06:00
l lint: ## lint the python
$(call msg,Linting)
2022-09-05 12:23:17 -05:00
@black generate.py
@black src/*.py --fast
assets: ## generate assets
2022-09-14 00:03:29 -05:00
@yartsu -o assets/help.svg -t "make help" -- make --no-print-directory help
2023-01-19 14:32:20 -06:00
define release_sh
./generate.py $(subst v,,$(VERSION)) > task.mk
sed -i 's/task.mk\/.*\/task.mk/task.mk\/$(VERSION)\/task.mk/g' README.md docs/index.md
2023-01-20 13:29:42 -06:00
sed -i 's/TASKMK_VERSION=.*/TASKMK_VERSION=$(VERSION)/' docs/init
2023-01-19 14:32:20 -06:00
git add task.mk README.md docs/index.md
git commit -m "release: $(VERSION)" --no-verify
git tag $(VERSION)
endef
release: version-check ## release new version of task.mk
2022-09-07 00:11:26 -05:00
$(call msg,Release Project)
2023-01-19 14:32:20 -06:00
$(call tbash,release_sh)
2022-09-05 12:23:17 -05:00
c clean: ## remove the generated files
@rm -f .task.mk
2022-09-14 00:03:29 -05:00
2023-01-19 13:43:29 -06:00
define version_check_sh
2023-01-20 12:45:36 -06:00
if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null; then
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} tag already exists); exit 1;
elif [[ "${VERSION}" == *'-'* ]]; then
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Uncommited or untagged work); exit 1;
2023-01-19 13:43:29 -06:00
exit 1
elif [[ $(shell echo "${VERSION}" | awk -F. '{ print NF }') -lt 3 ]];then\
$(call tprint-verbose,{a.red}VERSION INVALID!{a.end} Expected CalVer string)
2023-01-19 13:43:29 -06:00
exit 1
fi
endef
version-check: ##
2023-01-19 13:43:29 -06:00
@$(call tprint,>> version: {a.green}$(VERSION){a.end})
@$(call tbash,version_check_sh)
@$(call tprint,>> {a.green}VERSION LOOKS GOOD!{a.end})
2022-09-05 12:23:17 -05:00
info: ## demonstrate usage of tprint
2022-09-12 00:16:25 -05:00
$(call msg,Info Message)
2022-09-05 23:48:32 -05:00
$(call tprint,{a.black_on_cyan}This is task-print output:{a.end})
2022-09-07 00:11:26 -05:00
$(call tprint,$(mlmsg))
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
2022-09-05 12:23:17 -05:00
2022-09-07 15:48:46 -05:00
task.mk: $(TEMPLATES) generate.py
./generate.py $(VERSION) > task.mk
2022-09-05 12:23:17 -05:00
-include .task.cfg.dev.mk .task.cfg.mk