-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (93 loc) · 3.68 KB
/
Makefile
File metadata and controls
109 lines (93 loc) · 3.68 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
.PHONY: help install test demo lint format check build clean publish publish-patch
# Default target
help:
@echo "Available commands:"
@echo " make install - Install hatch and set up environment"
@echo " make test - Run all tests"
@echo " make demo - Run the demo"
@echo " make lint - Run linter (ruff)"
@echo " make format - Format code (ruff)"
@echo " make check - Run all checks (lint + format check)"
@echo " make build - Build package"
@echo " make clean - Clean build artifacts"
@echo " make publish - Bump version to today's date, commit, tag, and push"
@echo " make publish-patch - Publish patch version (for same-day releases)"
# =============================================================================
# Setup & Development
# =============================================================================
install:
pip install hatch
hatch env create
test:
hatch run test
demo:
hatch run demo
# =============================================================================
# Code Quality
# =============================================================================
lint:
hatch run lint
format:
hatch run format
check:
@echo "Running linter..."
@hatch run lint
@echo "Checking formatting..."
@hatch run format-check
@echo "All checks passed!"
# =============================================================================
# Building
# =============================================================================
build: clean
hatch build
clean:
hatch clean 2>/dev/null || true
rm -rf dist/ build/ *.egg-info
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
# =============================================================================
# Publishing
# =============================================================================
# Get current version from __init__.py
CURRENT_VERSION := $(shell grep -o "__version__ = '[^']*'" arbol/__init__.py | cut -d"'" -f2)
TODAY := $(shell date +%Y.%-m.%-d)
# Bump version to today's date and publish
publish: check test
@echo "Current version: $(CURRENT_VERSION)"
@if echo "$(CURRENT_VERSION)" | grep -q "^$(TODAY)$$"; then \
echo "Error: Version $(CURRENT_VERSION) is already today's date."; \
echo "Use 'make publish-patch' for same-day releases."; \
exit 1; \
fi
@echo "Updating version to: $(TODAY)"
@sed -i.bak "s/__version__ = '[^']*'/__version__ = '$(TODAY)'/" arbol/__init__.py && rm -f arbol/__init__.py.bak
@echo "Committing version bump..."
git add arbol/__init__.py
git commit -m "$(TODAY) release."
@echo "Creating tag v$(TODAY)..."
git tag "v$(TODAY)"
@echo "Pushing to origin..."
git push origin main --tags
@echo "Done! GitHub Actions will publish to PyPI."
# Publish patch version (for same-day releases)
publish-patch: check test
@echo "Current version: $(CURRENT_VERSION)"
@if echo "$(CURRENT_VERSION)" | grep -q "^$(TODAY)\."; then \
PATCH=$$(echo "$(CURRENT_VERSION)" | sed 's/$(TODAY)\.\([0-9]*\)/\1/'); \
NEW_PATCH=$$((PATCH + 1)); \
NEW_VERSION="$(TODAY).$$NEW_PATCH"; \
elif [ "$(CURRENT_VERSION)" = "$(TODAY)" ]; then \
NEW_VERSION="$(TODAY).1"; \
else \
NEW_VERSION="$(TODAY)"; \
fi; \
echo "Updating version to: $$NEW_VERSION"; \
sed -i.bak "s/__version__ = '[^']*'/__version__ = '$$NEW_VERSION'/" arbol/__init__.py && rm -f arbol/__init__.py.bak; \
echo "Committing version bump..."; \
git add arbol/__init__.py; \
git commit -m "$$NEW_VERSION release."; \
echo "Creating tag v$$NEW_VERSION..."; \
git tag "v$$NEW_VERSION"; \
echo "Pushing to origin..."; \
git push origin main --tags; \
echo "Done! GitHub Actions will publish to PyPI."