-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (82 loc) · 2.62 KB
/
Makefile
File metadata and controls
94 lines (82 loc) · 2.62 KB
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
VIRTUAL_ENV := ./.venv
PYTHON_VERSION := 3.14.3
UV := uv
# OS detection
ifeq ($(OS),Windows_NT)
YOUR_OS := Windows
MAKE := make
else
YOUR_OS := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
# Check if gmake exists, otherwise fall back to make
MAKE := $(shell command -v gmake >/dev/null 2>&1 && echo gmake || echo make)
endif
.PHONY: all
all: lint build
.PHONY: info
info:
@echo "Operating System : ${YOUR_OS}"
@echo "Python version : $(PYTHON_VERSION)"
@echo "uv version : $$($(UV) --version)"
@echo "make version : $$($(MAKE) --version | head -n 1)"
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
@rm -rf dist/ 2>/dev/null || true
@rm -rf build/ 2>/dev/null || true
@rm -rf *.egg-info 2>/dev/null || true
@rm -rf .venv 2>/dev/null || true
@rm -rf .ruff_cache 2>/dev/null || true
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
.PHONY: install
install: venv-ensure
@echo "Installing dependencies..."
$(UV) sync
.PHONY: venv-ensure
venv-ensure:
@if [ ! -d ".venv" ] || ! ./.venv/bin/python --version 2>/dev/null | grep -q "$(PYTHON_VERSION)"; then \
echo "Creating/Recreating venv with Python $(PYTHON_VERSION)"; \
$(UV) venv --python $(PYTHON_VERSION); \
else \
echo "Venv exists with correct Python version"; \
fi
.PHONY: lint
lint: venv-ensure
@echo "Running all linters..."
$(UV) run ruff check .
$(UV) run ruff format --check .
pnpm run lint:md
.PHONY: format
format: venv-ensure
@echo "Formatting code..."
$(UV) run ruff check --fix .
$(UV) run ruff format .
pnpm exec prettier --write "**/*.md"
.PHONY: build
build: venv-ensure clean
@echo "Building package..."
$(UV) build
.PHONY: bump
bump:
@echo "Bumping patch version..."
@NEW_V=$$( $(UV) run python3 -c "import re; \
path = 'mkdocs_material_ekgf/__init__.py'; \
content = open(path).read(); \
v = re.search(r'__version__ = \"(\d+\.\d+\.)(\d+)\"', content); \
new_v = v.group(1) + str(int(v.group(2)) + 1); \
new_content = re.sub(r'__version__ = \".*?\"', f'__version__ = \"{new_v}\"', content); \
open(path, 'w').write(new_content); \
print(new_v)" ); \
echo "Bumped version to $$NEW_V"; \
git add mkdocs_material_ekgf/__init__.py; \
git commit -m "build: bump version to $$NEW_V"; \
CURRENT_BRANCH=$$(git branch --show-current); \
git push origin $$CURRENT_BRANCH
@echo "Version bumped and pushed to $$CURRENT_BRANCH. Merge the PR to main to trigger CI tagging and release."
.PHONY: publish-test
publish-test: build
@echo "Publishing to TestPyPI..."
$(UV) run twine upload --repository testpypi dist/*
.PHONY: publish
publish: build
@echo "Publishing to PyPI..."
$(UV) run twine upload dist/*