-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
94 lines (72 loc) · 1.78 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.PHONY: \
clean full-clean \
lint check fmt \
tests doctests coverage \
build publish \
change clog \
release
clean:
rm -rf MANIFEST build dist
full-clean: clean
rm -rf .venv .tox .nox .pytest_cache .mypy_cache .ruff_cache .coverage*
# LINTING
lint:
hatch run lint:pc
check:
hatch run lint:check
fix:
hatch run lint:fix
hatch run lint:upgrade
# TESTS
test:
hatch test
coverage:
hatch test --cover
version-test:
hatch test --all --cover
doctest:
hatch test -- --xdoctest src/
# PACKAGING
build: clean
hatch build --clean --target wheel
publish: build
hatch publish
# CHANGELOG
CHANGE_TYPES := rm fix feat change
change: issue ?= _$(shell < /dev/urandom tr -dc A-Za-z0-9 | head -c9)
change: change_file := changes/$(issue).$(type).md
change:
ifneq ($(filter $(type),$(CHANGE_TYPES)),)
touch '$(change_file)'
$(EDITOR) '$(change_file)'
else
@echo "Given change type '$(type)' is not a suported value: $(CHANGE_TYPES)"
endif
clog:
hatch run project:towncrier build --draft --version Unreleased
# RELEASE
RELEASE_LEVELS := patch minor major
release:
ifneq ($(filter $(part),$(RELEASE_LEVELS)),)
# check git status
@if ! git diff-index --quiet HEAD; then \
echo "ERROR: git unclean!"; \
exit 1; \
fi
# get next version (for changelog)
$(eval new_version := $(shell \
hatch run project:bumpver update --dry --$(part) 2>&1 \
| grep 'New Version:' \
| awk '{print $$NF}' \
))
@echo "bump -> '$(new_version)'"
# write changelog
hatch run project:towncrier build --yes --version '$(new_version)'
if ! git diff --staged --exit-code; then \
git commit -m 'chore: add CHANGELOG for `$(new_version)`' --no-verify; \
fi
# bump version
hatch run project:bumpver update '--$(part)'
else
@echo "Given part '$(part)' is not a suported value: $(RELEASE_LEVELS)"
endif