build: switch to .task.mk

This commit is contained in:
Daylin Morgan 2023-01-20 11:24:52 -06:00
parent ff7d561ed8
commit 1cdd4ef8b4
2 changed files with 22 additions and 41 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
capture.svg capture.svg
.pdm.toml .pdm.toml
.task.mk
# Created by https://www.toptal.com/developers/gitignore/api/python # Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python # Edit at https://www.toptal.com/developers/gitignore?templates=python

View file

@ -1,17 +1,14 @@
VERSION ?= $(shell git describe --tags --always --dirty=-dev | sed 's/^v//g')
SRC_FILES := $(wildcard yartsu/*) SRC_FILES := $(wildcard yartsu/*)
VERSION := $(shell pdm show | grep "Installed" | awk -F ":" 'gsub(/ /, ""){print $$2}') # TODO: use git not pdm
.PHONY: lint typecheck build format .PHONY: lint typecheck build format
## apply formatting, linting and typechecking (default) check: lint typecheck ## apply formatting, linting and typechecking (default)
check: lint typecheck typcheck: ## perform typechecking
## perform typechecking
typcheck:
pdm run mypy yartsu pdm run mypy yartsu
## format/lint with pre-commit(black,isort,flake8) lint: ## format/lint with pre-commit(black,isort,flake8)
lint:
pdm run pre-commit run --all pdm run pre-commit run --all
.PHONY: dist release release.assets dist build .PHONY: dist release release.assets dist build
@ -20,27 +17,23 @@ release.assets: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu che
tar czf build/yartsu-$(VERSION)-x86_64-linux.tar.gz \ tar czf build/yartsu-$(VERSION)-x86_64-linux.tar.gz \
build/x86_64-unknown-linux-gnu/release/install/yartsu build/x86_64-unknown-linux-gnu/release/install/yartsu
## create github release and attach gzipped binary release: check-tag release-assets ## create github release and attach gzipped binary
release: check-tag release-assets
gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d
## publish to pypi with twine publish: check-version dist ## publish to pypi with twine
publish: check-version dist
twine upload dist/* twine upload dist/*
## build wheel/targz with pdm dist: ## build wheel/targz with pdm
dist:
pdm build pdm build
## build with pyoxidizer build: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ## build with pyoxidizer
build: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
build/shiv/yartsu: $(SRC_FILES) build/shiv/yartsu: $(SRC_FILES)
@echo "==> Building yartsu w/ shiv <==" @echo "==> Building yartsu w/ shiv <=="
@mkdir -p build/shiv @mkdir -p build/shiv
@shiv \ @shiv \
-c yartsu \ -c yartsu \
-o ./build/shiv/yartsu \ -o ./build/yartsu \
--preamble scripts/preamble.py \ --preamble scripts/preamble.py \
--reproducible \ --reproducible \
. .
@ -52,34 +45,29 @@ build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu: $(SRC_FILES)
.PHONY: install.bin install.shiv .PHONY: install.bin install.shiv
## install pyoxidizer binary install-bin: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ## install pyoxidizer binary
install.bin: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
@echo "==> Installing yartsu to ~/bin <==" @echo "==> Installing yartsu to ~/bin <=="
@cp ./build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ~/bin @cp ./build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ~/bin
## install shiv binary install-shiv: build/shiv/yartsu ## install shiv binary
install.shiv: build/shiv/yartsu
@echo "==> Installing yartsu to ~/bin <==" @echo "==> Installing yartsu to ~/bin <=="
@cp ./build/shiv/yartsu ~/bin @cp ./build/shiv/yartsu ~/bin
DOCS_RECIPES := $(patsubst %,docs.%,theme diff svg demo) DOCS_RECIPES := $(patsubst %,docs-%,theme diff svg demo)
.PHONY: docs $(DOCS_RECIPES) .PHONY: docs $(DOCS_RECIPES)
docs: $(DOCS_RECIPES) ## generate docs/svg
## generate docs/svg docs-theme:
docs: $(DOCS_RECIPES)
docs.theme:
@./scripts/theme-showcase-gen @./scripts/theme-showcase-gen
docs.diff: docs-diff:
@./scripts/rich-diff > docs/rich-diff.md @./scripts/rich-diff > docs/rich-diff.md
docs.svg: docs-svg:
@lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg @lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg
@yartsu -o assets/help.svg -t "yartsu --help" -- yartsu -h @yartsu -o assets/help.svg -t "yartsu --help" -- yartsu -h
docs.demo: docs-demo:
@python -c \ @python -c \
"from rich.console import Console; \ "from rich.console import Console; \
console = Console(force_terminal=True); \ console = Console(force_terminal=True); \
@ -87,8 +75,7 @@ docs.demo:
console.print(' [cyan]Nerd Fonts!');" | \ console.print(' [cyan]Nerd Fonts!');" | \
yartsu -w 25 -o assets/demo.svg yartsu -w 25 -o assets/demo.svg
## cleanup build and loose files clean: ## cleanup build and loose files
clean:
@rm -rf build dist capture.svg @rm -rf build dist capture.svg
# conditionals # conditionals
@ -103,12 +90,5 @@ check-version:
exit 1; \ exit 1; \
fi fi
.PHONY: help list -include .task.mk
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk))
FILL = 15
## Display this help screen
help: ## try `make help`
@awk '/^[a-z.A-Z_-]+:/ { helpMessage = match(lastLine, /^##(.*)/); \
if (helpMessage) { helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); printf "\033[36m%-$(FILL)s\033[0m%s\n"\
, helpCommand, helpMessage;}} { lastLine = $$0 }' $(MAKEFILE_LIST)