|
| 1 | +# Chainlit Community Release Engineering Guide |
| 2 | + |
| 3 | +## Version Management Strategy |
| 4 | + |
| 5 | +### Monorepo Versioning with Hatch |
| 6 | +- **Hatch-managed versions** using dynamic source from `__init__.py` |
| 7 | +- Configure per-package in `pyproject.toml`: |
| 8 | + ```toml |
| 9 | + [tool.hatch.version] |
| 10 | + source = "regex" |
| 11 | + path = "src/chainlit_<package>/__init__.py" |
| 12 | + pattern = '^__version__ = "(.+)"$' |
| 13 | + ``` |
| 14 | + |
| 15 | +### Version Bumping Protocol |
| 16 | +For each package (e.g. `chainlit-sqlalchemy`): |
| 17 | +```bash |
| 18 | +# Bump specific version |
| 19 | +hatch version 1.2.3 |
| 20 | + |
| 21 | +# Semantic increments |
| 22 | +hatch version minor # 0.1.0 → 0.2.0 |
| 23 | +hatch version micro # 0.1.0 → 0.1.1 |
| 24 | +hatch version major,rc # 1.0.0 → 2.0.0rc0 |
| 25 | +hatch version release # 2.0.0rc0 → 2.0.0 |
| 26 | +``` |
| 27 | + |
| 28 | +## Package Release Process |
| 29 | + |
| 30 | +### Pre-Release Validation |
| 31 | +1. Verify workspace integrity: |
| 32 | + ```bash |
| 33 | + uv sync --all-packages |
| 34 | + uv run pip check |
| 35 | + ``` |
| 36 | + |
| 37 | +2. Run full test matrix: |
| 38 | + ```bash |
| 39 | + ./scripts/ci.sh |
| 40 | + ``` |
| 41 | + |
| 42 | +### Build Process Updates |
| 43 | +```bash |
| 44 | +# Ensure Hatch recognizes dynamic version |
| 45 | +uv pip install hatch |
| 46 | + |
| 47 | +# Build with version from Hatch |
| 48 | +uv build --no-sources --strict \ |
| 49 | + --exclude-extras all \ |
| 50 | + --build-constraint ../../constraints.txt |
| 51 | +``` |
| 52 | + |
| 53 | +Key flags: |
| 54 | +- `--no-sources`: Ignore workspace sources |
| 55 | +- `--strict`: Fail on dependency resolution issues |
| 56 | +- `--exclude-extras`: Build base package only |
| 57 | + |
| 58 | +### Publishing Workflow |
| 59 | +1. Configure credentials: |
| 60 | + ```bash |
| 61 | + export UV_PUBLISH_TOKEN="pypi-xxxxxxxx" |
| 62 | + ``` |
| 63 | + |
| 64 | +2. Dry run validation: |
| 65 | + ```bash |
| 66 | + uv publish --dry-run --strict \ |
| 67 | + --index-url https://upload.pypi.org/legacy/ |
| 68 | + ``` |
| 69 | + |
| 70 | +3. Publish package: |
| 71 | + ```bash |
| 72 | + uv publish --no-sources --strict \ |
| 73 | + --index-url https://upload.pypi.org/legacy/ |
| 74 | + ``` |
| 75 | + |
| 76 | +4. Verify publication: |
| 77 | + ```bash |
| 78 | + uv pip install --force-reinstall chainlit-sqlalchemy==1.2.3 |
| 79 | + uv run python -c "from chainlit_sqlalchemy import __version__; print(__version__)" |
| 80 | + ``` |
| 81 | + |
| 82 | +## Workspace Management |
| 83 | + |
| 84 | +### Cross-Package Dependencies |
| 85 | +When package A (e.g. `pytest`) depends on package B (e.g. `sqlalchemy`): |
| 86 | +1. Release dependency first: |
| 87 | + ```bash |
| 88 | + uv publish -p packages/data_layers/sqlalchemy |
| 89 | + ``` |
| 90 | + |
| 91 | +2. Update dependent package constraints: |
| 92 | + ```toml |
| 93 | + # packages/pytest/pyproject.toml |
| 94 | + dependencies = [ |
| 95 | + "chainlit-sqlalchemy>=1.2.3,<2.0.0" |
| 96 | + ] |
| 97 | + ``` |
| 98 | + |
| 99 | +### Batch Publishing |
| 100 | +Publish all modified packages: |
| 101 | +```bash |
| 102 | +uv publish --workspace \ |
| 103 | + --index-url https://upload.pypi.org/legacy/ \ |
| 104 | + --strict |
| 105 | +``` |
| 106 | + |
| 107 | +## Security & Compliance |
| 108 | + |
| 109 | +### PyPI Configuration |
| 110 | +```toml |
| 111 | +# Single token in root .env |
| 112 | +UV_PUBLISH_TOKEN="pypi-xxxxxxxx" |
| 113 | +``` |
| 114 | + |
| 115 | +### Dependency Pinning |
| 116 | +Maintain `constraints.txt` in root: |
| 117 | +```bash |
| 118 | +uv pip compile requirements.txt --output-file constraints.txt \ |
| 119 | + --generate-hashes --no-sources |
| 120 | +``` |
| 121 | + |
| 122 | +## Post-Release Actions |
| 123 | + |
| 124 | +1. Tag releases with package prefixes: |
| 125 | + ```bash |
| 126 | + git tag sqlalchemy/v1.2.3 -m "chainlit-sqlalchemy 1.2.3" |
| 127 | + git push origin sqlalchemy/v1.2.3 |
| 128 | + ``` |
| 129 | + |
| 130 | +## Troubleshooting |
| 131 | + |
| 132 | +Common Issues | Resolution |
| 133 | +---|--- |
| 134 | +`BuildError: Missing build dependency` | `uv pip install "setuptools>=65" --resolution=lowest-direct` |
| 135 | +`PublishError: Invalid API token` | Verify token has `pypi-` prefix and package scope |
| 136 | +`VersionConflict` | Run `uv sync --all-packages --upgrade` |
| 137 | +`FileExistsError` | Remove `dist/` and `build/` directories before rebuilding |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +[uv Publishing Reference](https://docs.astral.sh/uv/guides/publish/) | |
| 142 | +[PEP 440 Spec](https://peps.python.org/pep-0440/) |
0 commit comments