- Python 3.11+
- PyPI account with API token
- Git repository with push access
pip install --upgrade build twineCreate ~/.pypirc:
[pypi]
username = __token__
password = pypi-...Or use environment variable:
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-...# Clean previous builds
rm -rf dist/ build/ src/*.egg-info
# Build package
python -m buildOutput:
dist/tip_generator-X.X.X-py3-none-any.whldist/tip_generator-X.X.X.tar.gz
# Check package before upload
twine check dist/*
# Upload to PyPI
twine upload dist/*The workflow .github/workflows/publish.yml automatically publishes on tag push:
# Update version in pyproject.toml first
# Then create and push tag
git tag v0.1.0
git push origin v0.1.0- Update
versioninpyproject.toml - Update
__version__insrc/tip_generator/__init__.py - Commit changes
- Create tag matching version
# Example: bump to 0.2.0
sed -i 's/version = "0.1.0"/version = "0.2.0"/' pyproject.toml
sed -i 's/__version__ = "0.1.0"/__version__ = "0.2.0"/' src/tip_generator/__init__.py
git commit -am "Bump version to 0.2.0"
git tag v0.2.0
git push origin master --tags# Build
python -m build
# Upload to TestPyPI first
twine upload --repository testpypi dist/*
# Test install
pip install --index-url https://test.pypi.org/simple/ tip-generatorpipx install drupaltools-tip-generator
drupaltools-tip-generator --help