Skip to main content

Safe Python package release CLI

Project description

puba

Safe Python Package Release CLI

A minimal, dependency-free CLI to safely check, build, and publish Python packages without risking secrets.


Features

  • Ensure git working directory is clean before releasing
  • Scan for secrets in the repo before publishing
  • Run tests automatically (via pytest if installed)
  • Build the package (python -m build)
  • Safely upload to PyPI or TestPyPI
  • Store your PyPI token securely in macOS Keychain, Windows Credential Manager, or Linux keyring
  • Dry run mode for testing builds without uploading
  • checks command to validate the repo without publishing
  • No external dependencies required for CLI parsing

Usage

1️⃣ Store PyPI token securely

puba auth
  • On macOS → stored in Keychain
  • On Windows → stored in Credential Manager
  • On Linux → stored in system keyring if available
  • Fallback → prompts you for input each time

2️⃣ Install optional dev tools (for tests, builds, and publishing)

If you want to run tests, build packages, or publish safely, install optional dependencies:

# zsh users: quote the extras to avoid glob errors
pip install ".[dev]"
  • Installs: pytest, build, twine
  • You can also install subsets:
    pip install ".[test]"   # only pytest
    pip install ".[build]"  # only build and twine
    

3️⃣ Run safety checks only

puba checks

Checks performed:

  • Git working directory is clean
  • Secret scan (requires gitleaks)
  • Runs tests (pytest)
  • Builds the package

No upload occurs in this step.


4️⃣ Publish package

puba publish

Options:

  • --test → Upload to TestPyPI instead of PyPI
  • --dry → Run all checks and build without uploading

Examples:

# Standard release
puba publish

# Upload to TestPyPI
puba publish --test

# Dry run (check + build only)
puba publish --dry

5️⃣ Help

puba help

Displays usage instructions and available commands.


Example Workflow

          +----------------+
          | puba auth |
          +----------------+
                   |
                   v
          +------------------+
          | puba checks |
          +------------------+
                   |
                   v
          +-------------------+
          | puba publish |
          +-------------------+
  1. Store token (one-time)
  2. Check repo before release
  3. Publish safely

Optional: test PyPI or dry-run:

puba publish --test
puba publish --dry

Notes

  • Secrets are never committed — always stored in system keyring or provided via environment variable PYPI_TOKEN.
  • Works on macOS, Windows, and Linux.
  • Can be integrated into CI/CD pipelines with environment variables:
export PYPI_TOKEN=pypi-xxxxxxxxxxxx
puba publish --dry

Recommended Tools (Optional)

  • pytest → for running tests automatically
  • gitleaks → for scanning secrets before publishing
  • build → Python build system (pip install build)
  • twine → for uploading packages (pip install twine)

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

puba-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

puba-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: puba-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for puba-0.1.1.tar.gz
Algorithm Hash digest
SHA256 79facc8a2fe1eb2438fe07af1bfc93e39e49a455163ce8df1ffb12816d6b59ac
MD5 038a46744132cc942483d3dfd916875b
BLAKE2b-256 cf2304ead1aa06a20573de05bde5de768e6fd7678356878428af44dbde8def1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: puba-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for puba-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d35f60550ca3052a02c69b76e46f7859b2a19306ac7c17296e1d74f7aaf478e3
MD5 eb2958d2ddd4db20c93bd289e6a93d25
BLAKE2b-256 b13bcc1b710ca92eb392a179e728f2709ff062eee0ef6b2d619043c6b9d4de2b

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