@@ -83,20 +83,28 @@ pytest -v
83
83
pre-commit run --all-files
84
84
```
85
85
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
+
87
90
```bash
88
91
python release.py
89
92
```
90
93
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.
96
102
97
103
## Quick Checklist
98
104
99
- Before pushing your changes, ensure:
105
+ ### Before Pushing Changes
106
+
107
+ Ensure your contribution meets these requirements:
100
108
101
109
- [ ] ✅ Code is formatted with `black`
102
110
- [ ] ✅ Imports are sorted with `isort`
@@ -105,6 +113,19 @@ Before pushing your changes, ensure:
105
113
- [ ] ✅ New features have type hints
106
114
- [ ] ✅ Documentation is updated if needed
107
115
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
+
108
129
## Making Changes
109
130
110
131
### 1. Create a Feature Branch
@@ -195,6 +216,146 @@ def test_pipe_run_with_invalid_name_raises_error(langbase_client):
195
216
assert "404" in str(exc_info.value)
196
217
```
197
218
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
+
198
359
## Need Help?
199
360
200
361
- Check existing issues and PRs
0 commit comments