Skip to main content

Automated release workflow for building and publishing Python packages to PyPI

Project description

PyPI Release Tool banner

kingkybel-pypi-release-tool

Automated release workflow for Python packages, including version bumping, test execution, build, upload, and git tagging.

Features

  • 🚀 Automated Release Flow: Handles release lifecycle from version checks to final upload
  • 🧪 Integrated Testing: Runs project tests before packaging
  • 📦 Build + Upload: Builds distributions and uploads with Twine
  • 🔢 Version Management: Supports patch, minor, and major bumps
  • 🧰 Interpreter Detection: Finds available Python interpreters and selects highest version
  • 🏷️ Git Integration: Commits, pushes, and tags release versions
  • 🛟 Dry-Run Support: Preview release actions without changing repository state

Installation

pip install kingkybel-pypi-release-tool

Or from source:

git clone https://github.com/kingkybel/PyPIReleaseTool.git
cd PyPIReleaseTool
pip install -e .

Quick Start

# Default patch release
python release_to_pypi.py

# Minor or major release
python release_to_pypi.py --minor
python release_to_pypi.py --major

# Dry-run only
python release_to_pypi.py --dry-run

CLI Usage

python release_to_pypi.py [--repo REPO_DIR] [--minor] [--major] [--dry-run]

Options:

  • --repo, -r: Target repository directory (defaults to current directory)
  • --minor, -m: Increment minor version (x.y.z -> x.y+1.0)
  • --major, -M: Increment major version (x.y.z -> x+1.0.0)
  • --dry-run: Show actions without changing files, git state, or PyPI

Release Script

For packaging-only flows aligned with modern publishing practice:

./release.sh --help
./release.sh --testpypi-only
./release.sh --skip-testpypi
./release.sh --skip-upload

Package Layout

PyPIReleaseTool/
├── assets/
│   └── banners/
│       └── pypi-release-tool-banner.svg
├── pypi_release_tool/
│   ├── __init__.py
│   ├── __main__.py
│   └── release_tool.py
├── release_to_pypi.py
├── pyproject.toml
├── setup.py
├── release.sh
├── requirements.txt
└── README.md

Requirements

  • Python 3.8+
  • Git configured with push access
  • Twine credentials in ~/.secrets using TWINE_USERNAME/TWINE_PASSWORD, or interactive token entry at upload time

PyPI Credentials

The Python release workflow (release_to_pypi.py) looks for Twine credentials in ~/.secrets first.

Example:

export TWINE_USERNAME="__token__"
export TWINE_PASSWORD="pypi-AgENdGVzdC5weXBpLm9yZwIk..."

Behavior:

  • If both TWINE_USERNAME and TWINE_PASSWORD are found in ~/.secrets, they are used automatically.
  • If one or both are missing, a warning is shown and you are prompted for the PyPI token/password securely.

Notes

  • The tool expects a valid pyproject.toml and package __init__.py with a __version__ field.
  • The default workflow assumes main as the primary git branch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kingkybel_pypi_release_tool-0.1.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kingkybel_pypi_release_tool-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file kingkybel_pypi_release_tool-0.1.1.tar.gz.

File metadata

File hashes

Hashes for kingkybel_pypi_release_tool-0.1.1.tar.gz
Algorithm Hash digest
SHA256 94c1e6a55d64f1d0fdf36bde7b60647a9069d8b327a24c2fe1f6cfa0c9e67e06
MD5 cfbd8a8bde6bb52ef57b6a6c4f40b627
BLAKE2b-256 8ff716532fe68d0e5d6b2ecd9f0204df134ce4f4d5722a3146b47828548a285f

See more details on using hashes here.

File details

Details for the file kingkybel_pypi_release_tool-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kingkybel_pypi_release_tool-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d75c4f5beceb2afac1d85907145ed072b65ee8cd47e9fbbbe2ffe082499f6ed1
MD5 bfcd8455b9bdedb3f34519a19425ab25
BLAKE2b-256 92c3969d67529e4366ba659d3190338968842d947cf855a489b6c46fa6842667

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page