Skip to content

Commit 7128408

Browse files
committed
feat: add pypi publishing
1 parent 523f5a3 commit 7128408

5 files changed

Lines changed: 229 additions & 86 deletions

File tree

.github/workflows/publish.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.11'
16+
- name: Install build dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install build twine
20+
- name: Build package
21+
run: python -m build
22+
- name: Check package
23+
run: twine check dist/*
24+
- name: Upload artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: Publish to PyPI
32+
needs: [build]
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: pypi
36+
url: https://pypi.org/project/claude-code-trees/
37+
permissions:
38+
id-token: write # IMPORTANT: mandatory for trusted publishing
39+
steps:
40+
- name: Download artifacts
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: dist
44+
path: dist/
45+
- name: Publish to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
48+
publish-to-testpypi:
49+
name: Publish to TestPyPI
50+
needs: [build]
51+
runs-on: ubuntu-latest
52+
environment:
53+
name: testpypi
54+
url: https://test.pypi.org/project/claude-code-trees/
55+
permissions:
56+
id-token: write # IMPORTANT: mandatory for trusted publishing
57+
steps:
58+
- name: Download artifacts
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: dist
62+
path: dist/
63+
- name: Publish to TestPyPI
64+
uses: pypa/gh-action-pypi-publish@release/v1
65+
with:
66+
repository-url: https://test.pypi.org/legacy/
67+
skip-existing: true

CHANGELOG.md

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,31 @@ All notable changes to Claude Code Trees will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.2.0] - 2024-01-19
8+
## [0.1.0] - 2024-01-19
99

1010
### Added
11+
- Initial production-ready implementation of Claude Code Trees
12+
- Orchestrator for managing multiple Claude instances across git worktrees
13+
- ClaudeCodeInstance wrapper for Claude SDK with retry logic and error handling
14+
- WorktreeManager for git worktree operations
15+
- SessionManager for persistent task management with dependencies
16+
- Database layer with SQLAlchemy for state persistence
17+
- CLI interface with Click for command-line operations
1118
- Comprehensive error handling for all Claude Code SDK errors
1219
- Retry logic with exponential backoff for transient failures
1320
- Structured logging throughout the codebase
1421
- Thread-safe operations with async locks
15-
- Production-ready features and hardening
16-
- Architecture documentation in README
17-
- Comprehensive test coverage (96 tests, all passing)
18-
19-
### Changed
20-
- Updated to use real claude-code-sdk package (v0.0.20+)
21-
- Migrated from Pydantic v1 to v2 syntax
22-
- Updated SQLAlchemy imports to use non-deprecated modules
23-
- Improved test mocking strategies
24-
- Enhanced documentation to reflect production status
25-
26-
### Fixed
27-
- All test failures (8 failing tests now passing)
28-
- Property mocking issues in tests
29-
- Deprecated Pydantic method calls (.json() → .model_dump_json())
30-
- Deprecated SQLAlchemy imports
31-
- Datetime mocking in orchestrator tests
32-
33-
### Removed
34-
- Conceptual framework disclaimer from README
35-
- Placeholder/mocked SDK implementations
36-
37-
## [0.1.0] - 2024-01-18
38-
39-
### Added
40-
- Initial implementation of Claude Code Trees
41-
- Orchestrator for managing multiple Claude instances
42-
- ClaudeCodeInstance wrapper for Claude SDK
43-
- WorktreeManager for git worktree operations
44-
- SessionManager for persistent task management
45-
- Database layer with SQLAlchemy
46-
- CLI interface with Click
47-
- Basic examples and documentation
22+
- Full test suite with 96 tests (all passing)
23+
- Complete documentation with architecture diagrams
24+
- Example scripts for common use cases
25+
- GitHub Actions workflow for PyPI publishing
26+
27+
### Features
28+
- Parallel execution of Claude instances in isolated worktrees
29+
- Task orchestration with dependency management
30+
- Persistent sessions with save/resume capability
31+
- Health monitoring and resource cleanup
32+
- Both CLI and Python API interfaces
4833

4934
### Dependencies
5035
- claude-code-sdk (>=0.0.20)

README.md

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
Claude Code Trees enables you to orchestrate multiple Claude Code instances across different git worktrees, allowing for parallel development workflows and sophisticated AI-powered coding tasks. Perfect for managing complex projects, running parallel experiments, or coordinating multi-faceted development work.
1111

12-
## 🚀 Quick Start
12+
## Quick Start
1313

1414
### Installation
1515

@@ -231,7 +231,7 @@ analysis_tasks = [
231231
results = await orchestrator.run_parallel_tasks(analysis_tasks)
232232
```
233233

234-
## 🛡️ Production Features
234+
## Features
235235

236236
### Error Handling & Resilience
237237

@@ -284,7 +284,7 @@ async with orchestrator:
284284
instances = await asyncio.gather(*tasks)
285285
```
286286

287-
## 🔧 Development
287+
## Development
288288

289289
### Setup
290290

@@ -325,53 +325,6 @@ python examples/parallel_tasks.py
325325
python examples/advanced_orchestration.py
326326
```
327327

328-
## 🏗️ Architecture
329-
330-
Claude Code Trees follows a modular, service-oriented architecture:
331-
332-
```
333-
┌─────────────────────────────────────────────────────────┐
334-
│ Orchestrator │
335-
│ (High-level coordination and resource management) │
336-
└─────────────┬───────────────────────────┬───────────────┘
337-
│ │
338-
┌─────────▼──────────┐ ┌─────────▼──────────┐
339-
│ ClaudeCodeInstance │ │ SessionManager │
340-
│ (Claude SDK wrap) │ │ (Task tracking) │
341-
└─────────┬──────────┘ └─────────┬──────────┘
342-
│ │
343-
┌─────────▼──────────┐ ┌─────────▼──────────┐
344-
│ WorktreeManager │ │ Database │
345-
│ (Git isolation) │ │ (SQLite/SQLAlch) │
346-
└────────────────────┘ └────────────────────┘
347-
```
348-
349-
- **Orchestrator**: Main coordination hub for managing multiple instances
350-
- **ClaudeCodeInstance**: Wrapper around claude-code-sdk with retry logic and error handling
351-
- **WorktreeManager**: Manages git worktrees for isolated development environments
352-
- **SessionManager**: Handles persistent sessions with task dependencies
353-
- **Database**: SQLAlchemy-based persistence layer for state management
354-
355-
## 📦 Dependencies
356-
357-
- **[claude-code-sdk](https://pypi.org/project/claude-code-sdk/)** (>=0.0.20): Official Claude Code Python SDK
358-
- **[anyio](https://github.com/agronholm/anyio)** (>=4.0.0): Async runtime compatibility
359-
- **[GitPython](https://github.com/gitpython-developers/GitPython)** (>=3.1.40): Git worktree management
360-
- **[SQLAlchemy](https://www.sqlalchemy.org/)** (>=2.0.0): Database ORM
361-
- **[Pydantic](https://pydantic-docs.helpmanual.io/)** (>=2.0.0): Data validation
362-
- **[Click](https://click.palletsprojects.com/)** (>=8.0.0): CLI framework
363-
- **[Rich](https://github.com/Textualize/rich)** (>=13.0.0): Terminal formatting
364-
365-
## 🤝 Contributing
366-
367-
Contributions are welcome! Please feel free to submit a Pull Request.
368-
369-
## 📄 License
370-
371-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
372-
373328
---
374329

375-
**Claude Code Trees** - Production-ready orchestration for AI-powered development workflows.
376-
377330
Built with ❤️ by [Rizome Labs](https://rizome.dev)

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "claude-code-trees"
3-
version = "0.2.0"
3+
version = "0.1.0"
44
description = "Production-ready Python library for managing Claude Code instances on git worktrees"
55
authors = [
66
{name = "samjtro", email = "hi@samjtro.com"},
@@ -17,7 +17,7 @@ dependencies = [
1717
requires-python = ">=3.10,<4.0"
1818
readme = "README.md"
1919
license = {text = "MIT"}
20-
keywords = ["claude", "code", "git", "worktree", "ai"]
20+
keywords = ["claude", "code", "git", "worktree", "ai", "orchestration", "development"]
2121
classifiers = [
2222
"Development Status :: 4 - Beta",
2323
"Intended Audience :: Developers",
@@ -28,6 +28,13 @@ classifiers = [
2828
"Programming Language :: Python :: 3.12",
2929
]
3030

31+
[project.urls]
32+
Homepage = "https://github.com/rizome-dev/claude-code-trees"
33+
Repository = "https://github.com/rizome-dev/claude-code-trees"
34+
Documentation = "https://github.com/rizome-dev/claude-code-trees#readme"
35+
"Issue Tracker" = "https://github.com/rizome-dev/claude-code-trees/issues"
36+
Changelog = "https://github.com/rizome-dev/claude-code-trees/blob/main/CHANGELOG.md"
37+
3138
[project.optional-dependencies]
3239
dev = [
3340
"pytest>=7.0.0",

scripts/release.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
# Release script for claude-code-trees
3+
# Usage: ./scripts/release.sh [patch|minor|major]
4+
5+
set -e
6+
7+
# Colors for output
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
NC='\033[0m' # No Color
12+
13+
# Default to patch version
14+
VERSION_TYPE=${1:-patch}
15+
16+
echo -e "${GREEN}🚀 Preparing release for claude-code-trees${NC}"
17+
18+
# Get current version from pyproject.toml
19+
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2)
20+
echo -e "${YELLOW}Current version: $CURRENT_VERSION${NC}"
21+
22+
# Calculate new version
23+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
24+
MAJOR=${VERSION_PARTS[0]}
25+
MINOR=${VERSION_PARTS[1]}
26+
PATCH=${VERSION_PARTS[2]}
27+
28+
case $VERSION_TYPE in
29+
major)
30+
MAJOR=$((MAJOR + 1))
31+
MINOR=0
32+
PATCH=0
33+
;;
34+
minor)
35+
MINOR=$((MINOR + 1))
36+
PATCH=0
37+
;;
38+
patch)
39+
PATCH=$((PATCH + 1))
40+
;;
41+
*)
42+
echo -e "${RED}Invalid version type. Use: patch, minor, or major${NC}"
43+
exit 1
44+
;;
45+
esac
46+
47+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
48+
echo -e "${GREEN}New version: $NEW_VERSION${NC}"
49+
50+
# Update version in pyproject.toml
51+
if [[ "$OSTYPE" == "darwin"* ]]; then
52+
# macOS
53+
sed -i '' "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
54+
else
55+
# Linux
56+
sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
57+
fi
58+
59+
# Update version in __init__.py if it exists
60+
if [ -f "src/claude_code_trees/__init__.py" ]; then
61+
if grep -q "__version__" src/claude_code_trees/__init__.py; then
62+
if [[ "$OSTYPE" == "darwin"* ]]; then
63+
sed -i '' "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" src/claude_code_trees/__init__.py
64+
else
65+
sed -i "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" src/claude_code_trees/__init__.py
66+
fi
67+
else
68+
echo "__version__ = \"$NEW_VERSION\"" >> src/claude_code_trees/__init__.py
69+
fi
70+
fi
71+
72+
# Prompt for changelog entry
73+
echo -e "${YELLOW}Enter changelog entry for v$NEW_VERSION (press Ctrl+D when done):${NC}"
74+
CHANGELOG_ENTRY=$(cat)
75+
76+
# Update CHANGELOG.md
77+
if [ -f "CHANGELOG.md" ]; then
78+
# Create temporary file with new entry
79+
cat > /tmp/changelog_new.md << EOF
80+
# Changelog
81+
82+
All notable changes to Claude Code Trees will be documented in this file.
83+
84+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
85+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
86+
87+
## [$NEW_VERSION] - $(date +%Y-%m-%d)
88+
89+
$CHANGELOG_ENTRY
90+
91+
EOF
92+
93+
# Append rest of changelog (skipping header)
94+
tail -n +7 CHANGELOG.md >> /tmp/changelog_new.md
95+
96+
# Replace changelog
97+
mv /tmp/changelog_new.md CHANGELOG.md
98+
fi
99+
100+
# Build the package to verify
101+
echo -e "${YELLOW}Building package...${NC}"
102+
pdm build
103+
104+
# Run tests
105+
echo -e "${YELLOW}Running tests...${NC}"
106+
pdm run test || {
107+
echo -e "${RED}Tests failed! Aborting release.${NC}"
108+
exit 1
109+
}
110+
111+
# Git operations
112+
echo -e "${YELLOW}Committing changes...${NC}"
113+
git add pyproject.toml CHANGELOG.md src/claude_code_trees/__init__.py
114+
git commit -m "Release v$NEW_VERSION"
115+
116+
# Create tag
117+
echo -e "${YELLOW}Creating tag v$NEW_VERSION...${NC}"
118+
git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION"
119+
120+
echo -e "${GREEN}✅ Release prepared successfully!${NC}"
121+
echo ""
122+
echo "Next steps:"
123+
echo " 1. Review the changes: git show"
124+
echo " 2. Push to GitHub: git push && git push --tags"
125+
echo " 3. Create release on GitHub: https://github.com/rizome-dev/claude-code-trees/releases/new"
126+
echo " - Tag: v$NEW_VERSION"
127+
echo " - Title: v$NEW_VERSION"
128+
echo " - Copy description from CHANGELOG.md"
129+
echo " 4. The GitHub Action will automatically publish to PyPI"
130+
echo ""
131+
echo -e "${YELLOW}Or run: git push && git push --tags && gh release create v$NEW_VERSION --title \"v$NEW_VERSION\" --notes-file CHANGELOG.md${NC}"

0 commit comments

Comments
 (0)