|
1 | | -.PHONY: clean clean-pyc clean-build clean-test clean-all test run build publish help install dev-install version bump-patch bump-minor bump-major release |
| 1 | +.PHONY: clean clean-pyc clean-build clean-test clean-all test run build publish publish-test publish-manual help install dev-install version bump-patch bump-minor bump-major release |
2 | 2 |
|
3 | 3 | # Default target |
4 | 4 | help: |
|
27 | 27 | @echo " bump-minor - Bump minor version (0.X.0)" |
28 | 28 | @echo " bump-major - Bump major version (X.0.0)" |
29 | 29 | @echo " publish - Create tag and trigger automated release" |
| 30 | + @echo " publish-test - Upload to TestPyPI for testing" |
| 31 | + @echo " publish-manual - Manually upload to PyPI (requires PYPI_TOKEN)" |
30 | 32 | @echo " release - Alias for publish" |
31 | 33 |
|
32 | 34 | # Basic clean - Python bytecode and common artifacts |
@@ -265,6 +267,101 @@ publish: |
265 | 267 | # Alias for publish |
266 | 268 | release: publish |
267 | 269 |
|
| 270 | +# ============================================================================ |
| 271 | +# PyPI Publishing Targets |
| 272 | +# ============================================================================ |
| 273 | + |
| 274 | +# Upload to TestPyPI for testing |
| 275 | +publish-test: build |
| 276 | + @echo "Publishing to TestPyPI..." |
| 277 | + @echo "" |
| 278 | + @version=$$(grep '^version = ' pyproject.toml | cut -d'"' -f2); \ |
| 279 | + echo "Version: $$version"; \ |
| 280 | + echo ""; \ |
| 281 | + if command -v uv >/dev/null 2>&1; then \ |
| 282 | + uv run twine upload --repository testpypi dist/*; \ |
| 283 | + else \ |
| 284 | + python3 -m twine upload --repository testpypi dist/*; \ |
| 285 | + fi; \ |
| 286 | + echo ""; \ |
| 287 | + echo "✓ Uploaded to TestPyPI!"; \ |
| 288 | + echo ""; \ |
| 289 | + echo "Install with:"; \ |
| 290 | + echo " pip install --index-url https://test.pypi.org/simple/ chuk-tool-processor==$$version" |
| 291 | + |
| 292 | +# Manual publish to PyPI (requires PYPI_TOKEN environment variable) |
| 293 | +publish-manual: build |
| 294 | + @echo "Manual PyPI Publishing" |
| 295 | + @echo "======================" |
| 296 | + @echo "" |
| 297 | + @version=$$(grep '^version = ' pyproject.toml | cut -d'"' -f2); \ |
| 298 | + tag="v$$version"; \ |
| 299 | + echo "Version: $$version"; \ |
| 300 | + echo "Tag: $$tag"; \ |
| 301 | + echo ""; \ |
| 302 | + \ |
| 303 | + echo "Pre-flight checks:"; \ |
| 304 | + echo "=================="; \ |
| 305 | + \ |
| 306 | + if git diff --quiet && git diff --cached --quiet; then \ |
| 307 | + echo "✓ Working directory is clean"; \ |
| 308 | + else \ |
| 309 | + echo "✗ Working directory has uncommitted changes"; \ |
| 310 | + echo ""; \ |
| 311 | + git status --short; \ |
| 312 | + echo ""; \ |
| 313 | + echo "Please commit or stash your changes before publishing."; \ |
| 314 | + exit 1; \ |
| 315 | + fi; \ |
| 316 | + \ |
| 317 | + if git tag -l | grep -q "^$$tag$$"; then \ |
| 318 | + echo "✓ Tag $$tag exists"; \ |
| 319 | + else \ |
| 320 | + echo "⚠ Tag $$tag does not exist yet"; \ |
| 321 | + echo ""; \ |
| 322 | + read -p "Create tag now? (y/N) " -n 1 -r; \ |
| 323 | + echo ""; \ |
| 324 | + if [[ $$REPLY =~ ^[Yy]$$ ]]; then \ |
| 325 | + git tag -a "$$tag" -m "Release $$tag"; \ |
| 326 | + echo "✓ Tag created locally"; \ |
| 327 | + else \ |
| 328 | + echo "Continuing without creating tag..."; \ |
| 329 | + fi; \ |
| 330 | + fi; \ |
| 331 | + \ |
| 332 | + echo ""; \ |
| 333 | + echo "This will upload version $$version to PyPI"; \ |
| 334 | + echo ""; \ |
| 335 | + read -p "Continue? (y/N) " -n 1 -r; \ |
| 336 | + echo ""; \ |
| 337 | + if [[ ! $$REPLY =~ ^[Yy]$$ ]]; then \ |
| 338 | + echo "Aborted."; \ |
| 339 | + exit 1; \ |
| 340 | + fi; \ |
| 341 | + \ |
| 342 | + echo ""; \ |
| 343 | + echo "Uploading to PyPI..."; \ |
| 344 | + if [ -n "$$PYPI_TOKEN" ]; then \ |
| 345 | + if command -v uv >/dev/null 2>&1; then \ |
| 346 | + uv run twine upload --username __token__ --password "$$PYPI_TOKEN" dist/*; \ |
| 347 | + else \ |
| 348 | + python3 -m twine upload --username __token__ --password "$$PYPI_TOKEN" dist/*; \ |
| 349 | + fi; \ |
| 350 | + else \ |
| 351 | + if command -v uv >/dev/null 2>&1; then \ |
| 352 | + uv run twine upload dist/*; \ |
| 353 | + else \ |
| 354 | + python3 -m twine upload dist/*; \ |
| 355 | + fi; \ |
| 356 | + fi; \ |
| 357 | + echo ""; \ |
| 358 | + echo "✓ Published to PyPI!"; \ |
| 359 | + echo ""; \ |
| 360 | + if git tag -l | grep -q "^$$tag$$"; then \ |
| 361 | + echo "Push tag with: git push origin $$tag"; \ |
| 362 | + fi; \ |
| 363 | + echo "Install with: pip install chuk-tool-processor==$$version" |
| 364 | + |
268 | 365 | # Check code quality |
269 | 366 | lint: |
270 | 367 | @echo "Running linters..." |
|
0 commit comments