-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (63 loc) · 1.93 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
.DEFAULT_GOAL := all
.PHONY: all
all: format check test version
.PHONY: sync
sync:
@uv sync --all-extras
.PHONY: help
help: Makefile
@sed -n 's/^##//p' $< | sort
## upgrade : Update pre-commit configuration.
.PHONY: upgrade
upgrade: sync
uv run pre-commit autoupdate
## check : Execute pre-commit hooks.
.PHONY: check
check: sync
uv run pre-commit run --all-files
## format : Format code.
.PHONY: format
format: sync
uv run ruff format -q .
## test : Execute tests.
.PHONY: test
test: sync
uv run pytest -q
## version : Show which version is detected
CURRENT:=$(subst v,,$(shell git describe --abbrev=0 --tags))
PARTS:=$(subst ., ,$(CURRENT))
MAJOR:=$(word 1, $(PARTS))
MINOR:=$(word 2, $(PARTS))
PATCH:=$(word 3, $(PARTS))
VERSION:=$(MAJOR).$(MINOR).$(PATCH)
.PHONY: version
version:
ifeq "${CURRENT}" "${VERSION}"
@echo "Current version: ${CURRENT}"
else
@echo "Version mismatch: ${CURRENT} != ${VERSION}"
endif
# release : Use the value of `NEXT_VERSION` to create new release
.PHONY: release
release: test version
@echo "Next version: ${NEXT_VERSION}"
@sed -E -e "s/${CURRENT}/${NEXT_VERSION}/" -i '' README.md pyproject.toml
@uv lock
@git add README.md pyproject.toml uv.lock
git commit -m "chore: release version ${NEXT_VERSION}" && git tag "v${NEXT_VERSION}"
## release-patch : Increase patch version in files, commit and tag with git.
.PHONY: release-patch
release-patch: NEXT_VERSION:=${MAJOR}.${MINOR}.$$((${PATCH}+1))
release-patch: release
## release-minor : Increase minor version in files, commit and tag with git.
.PHONY: release-minor
release-minor: NEXT_VERSION:=${MAJOR}.$$((${MINOR}+1)).0
release-minor: release
## release-major : Increase major version in files, commit and tag with git.
.PHONY: release-major
release-major: NEXT_VERSION:=$$((${MAJOR}+1)).0.0
release-major: release
## clean : Remove virtual environment.
.PHONY: clean
clean:
rm -r .venv