Skip to content

Commit c3f7590

Browse files
committed
👌 IMPROVE: formatting
1 parent 32658ab commit c3f7590

File tree

1 file changed

+168
-7
lines changed

1 file changed

+168
-7
lines changed

CONTRIBUTING.md

Lines changed: 168 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,28 @@ pytest -v
8383
pre-commit run --all-files
8484
```
8585
86-
### 6. Release a new version
86+
### 6. Release a New Version
87+
88+
The release process is automated with an interactive script. **Only maintainers should create releases.**
89+
8790
```bash
8891
python release.py
8992
```
9093
91-
### 3. Optional: Publish to PyPI
92-
```
93-
python -m build
94-
twine upload dist/*
95-
```
94+
The script will guide you through:
95+
- Choosing version bump type (patch/minor/major)
96+
- Writing release notes
97+
- Updating version files
98+
- Committing and pushing changes
99+
- Building and uploading to PyPI
100+
101+
See the [Release Process](#release-process) section below for detailed instructions.
96102
97103
## Quick Checklist
98104
99-
Before pushing your changes, ensure:
105+
### Before Pushing Changes
106+
107+
Ensure your contribution meets these requirements:
100108
101109
- [ ] ✅ Code is formatted with `black`
102110
- [ ] ✅ Imports are sorted with `isort`
@@ -105,6 +113,19 @@ Before pushing your changes, ensure:
105113
- [ ] ✅ New features have type hints
106114
- [ ] ✅ Documentation is updated if needed
107115
116+
### Before Creating a Release (Maintainers Only)
117+
118+
Before running `python release.py`, ensure:
119+
120+
- [ ] ✅ All tests pass: `pytest`
121+
- [ ] ✅ Code is properly formatted: `pre-commit run --all-files`
122+
- [ ] ✅ Working directory is clean: `git status`
123+
- [ ] ✅ On main branch and up to date: `git pull origin main`
124+
- [ ] ✅ Have PyPI credentials configured in `~/.pypirc` (see PyPI Configuration section)
125+
- [ ] ✅ Have dev dependencies installed: `pip install -r requirements-dev.txt`
126+
- [ ] ✅ Reviewed changes since last release
127+
- [ ] ✅ Prepared release notes describing changes
128+
108129
## Making Changes
109130
110131
### 1. Create a Feature Branch
@@ -195,6 +216,146 @@ def test_pipe_run_with_invalid_name_raises_error(langbase_client):
195216
assert "404" in str(exc_info.value)
196217
```
197218
219+
## Release Process
220+
221+
**⚠️ Note: Only maintainers with PyPI access should perform releases.**
222+
223+
### Prerequisites for Releases
224+
225+
Before creating a release, ensure you have:
226+
227+
1. **PyPI Account & Access**
228+
- Account on [PyPI](https://pypi.org) and [Test PyPI](https://test.pypi.org)
229+
- Maintainer access to the `langbase` package
230+
- Configured `~/.pypirc` with credentials (see configuration below)
231+
232+
2. **Required Tools**
233+
234+
These are already installed with dev dependencies:
235+
```bash
236+
pip install -r requirements-dev.txt # Includes build and twine
237+
```
238+
239+
3. **Clean Working Directory**
240+
```bash
241+
git status # Should show no uncommitted changes
242+
git pull origin main # Ensure you're up to date
243+
```
244+
245+
### PyPI Configuration (~/.pypirc)
246+
247+
Create or update your `~/.pypirc` file with your PyPI credentials:
248+
249+
```ini
250+
[distutils]
251+
index-servers =
252+
pypi
253+
testpypi
254+
255+
[pypi]
256+
username = __token__
257+
password = pypi-your-api-token-here
258+
259+
[testpypi]
260+
repository = https://test.pypi.org/legacy/
261+
username = __token__
262+
password = pypi-your-test-api-token-here
263+
```
264+
265+
**To get API tokens:**
266+
1. **PyPI**: Go to [PyPI Account Settings](https://pypi.org/manage/account/) → API tokens → "Add API token"
267+
2. **Test PyPI**: Go to [Test PyPI Account Settings](https://test.pypi.org/manage/account/) → API tokens → "Add API token"
268+
269+
**Security Notes:**
270+
- Use API tokens instead of passwords (more secure)
271+
- Set appropriate permissions (project-scoped tokens recommended)
272+
- Keep your `~/.pypirc` file private (chmod 600)
273+
274+
### Release Types
275+
276+
Choose the appropriate version bump:
277+
278+
- **patch** (0.1.0 → 0.1.1): Bug fixes, documentation updates, small improvements
279+
- **minor** (0.1.0 → 0.2.0): New features, backwards compatible changes
280+
- **major** (0.1.0 → 1.0.0): Breaking changes, major API updates
281+
282+
### Step-by-Step Release Process
283+
284+
1. **Run the Release Script**
285+
```bash
286+
python release.py
287+
```
288+
289+
2. **Follow Interactive Prompts**
290+
291+
The script will ask you to:
292+
- Choose release type (patch/minor/major)
293+
- Enter release message describing changes
294+
- Confirm version bump
295+
- Choose between Test PyPI or Production PyPI
296+
297+
3. **What the Script Does Automatically**
298+
299+
- Updates version in `pyproject.toml` and `langbase/__init__.py`
300+
- Updates `CHANGELOG.md` with release notes
301+
- Commits changes with conventional commit message
302+
- Pushes to GitHub (optional)
303+
- Builds the package (`python -m build`)
304+
- Uploads to PyPI/Test PyPI (`twine upload`)
305+
306+
### Test Releases
307+
308+
For testing releases before production:
309+
310+
1. Run `python release.py`
311+
2. Answer "y" when asked about Test PyPI
312+
3. This uploads to https://test.pypi.org/project/langbase/
313+
4. Test install: `pip install --index-url https://test.pypi.org/simple/ langbase`
314+
315+
**Note**: Test releases don't commit to git, so you can reset changes after testing.
316+
317+
### Production Releases
318+
319+
1. Run `python release.py`
320+
2. Answer "n" when asked about Test PyPI
321+
3. The package will be uploaded to https://pypi.org/project/langbase/
322+
4. Changes are committed and pushed to GitHub
323+
324+
### Post-Release Checklist
325+
326+
After a successful release:
327+
328+
- [ ] ✅ Verify the new version appears on [PyPI](https://pypi.org/project/langbase/)
329+
- [ ] ✅ Test install the new version: `pip install langbase=={version}`
330+
- [ ] ✅ Check that GitHub has the release commit
331+
- [ ] ✅ Update any dependent projects or documentation
332+
- [ ] ✅ Announce the release (Discord, social media, etc.)
333+
334+
### Troubleshooting Releases
335+
336+
**Common Issues:**
337+
338+
1. **PyPI Upload Fails**
339+
- Check your `~/.pypirc` configuration
340+
- Ensure you have maintainer access
341+
- Version might already exist (can't overwrite)
342+
343+
2. **Pre-commit Hooks Fail**
344+
- The script retries automatically
345+
- Hooks may modify files (formatting, etc.)
346+
- Script will re-stage and retry up to 3 times
347+
348+
**Recovery:**
349+
350+
If a release fails partway through:
351+
```bash
352+
# Reset version changes (if not yet committed)
353+
git checkout -- pyproject.toml langbase/__init__.py CHANGELOG.md
354+
355+
# Or if committed but not pushed, reset the last commit
356+
git reset --soft HEAD~1
357+
```
358+
198359
## Need Help?
199360

200361
- Check existing issues and PRs

0 commit comments

Comments
 (0)