This document describes the process for releasing new versions of the Segmind Python SDK to PyPI.
Before you can create releases, ensure you have:
- Maintainer access to the PyPI package "segmind"
- Write access to the GitHub repository
- Trusted Publisher configured on PyPI (recommended) or API tokens set up
We follow Semantic Versioning:
- Major version (X.0.0): Breaking changes that require code updates
- Minor version (0.X.0): New features that are backwards-compatible
- Patch version (0.0.X): Bug fixes and minor improvements
-
Update version in
segmind/__init__.py:__version__ = "X.Y.Z"
-
Update CHANGELOG.md (if exists):
- Move items from "Unreleased" to a new version section
- Add release date
- Create comparison links
-
Run tests locally:
make test # or pytest tests/ -v
-
Run linting:
make lint # or pre-commit run --all-files -
Test building locally (optional but recommended):
make build-check # or python -m build && twine check dist/*
-
Commit changes:
git add segmind/__init__.py CHANGELOG.md git commit -m "Bump version to X.Y.Z" git push origin main
Before publishing to production PyPI, test the release on TestPyPI:
-
Trigger manual workflow:
- Go to GitHub Actions → "Publish to PyPI" workflow
- Click "Run workflow"
- Select branch:
main - Select environment:
testpypi - Click "Run workflow"
-
Monitor workflow:
- Wait for all jobs to complete
- Check that tests pass
- Verify build succeeds
- Confirm publication to TestPyPI
-
Verify on TestPyPI:
- Visit: https://test.pypi.org/project/segmind/
- Check version number
- Verify README renders correctly
- Check metadata (links, description, etc.)
-
Test installation from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ segmind
Note:
--extra-index-urlis needed for dependencies that aren't on TestPyPI -
Test the installed package:
import segmind print(segmind.__version__) # Test basic functionality client = segmind.SegmindClient(api_key="test")
Once testing is complete:
-
Create a Git tag:
git tag -a v0.1.0 -m "Release version 0.1.0" git push origin v0.1.0 -
Create GitHub Release:
- Go to GitHub repository → Releases → "Draft a new release"
- Choose tag:
v0.1.0(the tag you just created) - Release title:
v0.1.0orVersion 0.1.0 - Description: Copy relevant sections from CHANGELOG.md
- Click "Publish release"
-
Automatic publishing:
- Creating the release automatically triggers the publishing workflow
- The workflow will:
- Run all tests
- Run linting checks
- Build the package
- Publish to PyPI
-
Monitor the workflow:
- Go to GitHub Actions
- Watch the "Publish to PyPI" workflow
- Ensure all jobs complete successfully
-
Verify on PyPI:
- Visit: https://pypi.org/project/segmind/
- Check the new version is live
- Verify README and metadata
-
Test installation:
pip install --upgrade segmind python -c "import segmind; print(segmind.__version__)"
If you need to publish immediately without creating a GitHub Release:
- Trigger manual workflow:
- Go to GitHub Actions → "Publish to PyPI" workflow
- Click "Run workflow"
- Select branch:
main - Select environment:
pypi - Click "Run workflow"
Problem: Tests or linting fail during the workflow.
Solution:
- Check the workflow logs to identify failing tests/checks
- Fix the issues locally
- Run tests and linting locally to verify fixes
- Commit and push fixes
- Retry the release process
Problem: Cannot publish because version already exists.
Solution:
- You cannot replace an existing version on PyPI
- Bump the version number in
segmind/__init__.py - Commit and push
- Retry the release with the new version
Problem: Workflow fails with authentication error.
Solution:
- Verify Trusted Publisher is configured correctly on PyPI
- Check that:
- Repository name matches exactly
- Workflow filename is correct (
publish.yml) - Environment name matches (
pypiortestpypi)
- If Trusted Publisher isn't configured, use API tokens instead:
- Add
PYPI_API_TOKENto GitHub secrets - Modify workflow to use token authentication
- Add
Problem: README shows as plain text or has rendering errors.
Solution:
- Ensure README.md uses standard markdown (avoid GitHub-specific syntax)
- Run
twine check dist/*locally to validate - Test on TestPyPI first to preview rendering
- Go to https://pypi.org/manage/account/publishing/
- Scroll to "Add a new pending publisher"
- Fill in:
- PyPI Project Name:
segmind - Owner:
segmind(GitHub organization) - Repository name:
segmind-python - Workflow name:
publish.yml - Environment name:
pypi
- PyPI Project Name:
- Click "Add"
- Go to https://test.pypi.org/manage/account/publishing/
- Scroll to "Add a new pending publisher"
- Fill in the same details as above (but use
testpypias environment name) - Click "Add"
Note: You may need to publish once using API tokens before you can configure Trusted Publishers for an existing project.
If Trusted Publishers aren't available:
-
Generate PyPI API Token:
- Go to https://pypi.org/manage/account/token/
- Create token scoped to "segmind" project
- Copy the token (starts with
pypi-)
-
Add to GitHub Secrets:
- Go to GitHub repository → Settings → Secrets and variables → Actions
- Add secret:
PYPI_API_TOKENwith the token value - Repeat for TestPyPI token:
TEST_PYPI_API_TOKEN
-
Update workflow to use tokens instead of Trusted Publishers (modify the publish jobs)
- Always test on TestPyPI first before production releases
- Keep CHANGELOG.md updated with all changes
- Follow semantic versioning strictly
- Run tests locally before creating releases
- Create meaningful release notes in GitHub Releases
- Announce releases to users (if applicable)
- Monitor PyPI download stats to track adoption