Skip to main content

A minimal Python package for testing PyPI publishing

Project description

Test Publish

A minimal Python package for testing PyPI publishing with Poetry and GitHub Actions.

Features

  • 📦 Poetry for dependency management
  • 🚀 GitHub Actions for CI/CD
  • 🔄 Semantic versioning with semantic-release
  • ✅ Automated PR checks with commitlint
  • 📝 Conventional commit validation

Installation

pip install test-publish

Usage

from test_publish import hello

# Simple greeting
print(hello())  # Output: Hello, World!

# Custom greeting
print(hello("Python"))  # Output: Hello, Python!

Development

Setup

  1. Install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
  1. Install Node.js (for semantic-release):
# On macOS with Homebrew
brew install node

# On Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Install Python dependencies:
poetry install
  1. Install Node.js dependencies:
npm install
  1. Activate the virtual environment:
poetry shell

Running Tests

poetry run pytest

Code Quality

Run linting and formatting:

poetry run black src tests
poetry run ruff check src tests

Releasing

This project uses semantic-release (Node.js) for automated versioning and publishing.

Commit Message Format

All commits must follow the Conventional Commits specification:

<type>(<scope>): <description>

[optional body]

[optional footer]

Types:

  • feat: A new feature (triggers minor version bump, e.g., 1.0.0 → 1.1.0)
  • fix: A bug fix (triggers patch version bump, e.g., 1.0.0 → 1.0.1)
  • perf: Performance improvement (triggers patch version bump)
  • docs: Documentation only changes (no version bump)
  • style: Changes that don't affect code meaning (no version bump)
  • refactor: Code change that neither fixes a bug nor adds a feature (no version bump)
  • test: Adding missing tests (no version bump)
  • build: Changes to build system or dependencies (no version bump)
  • ci: Changes to CI configuration (no version bump)
  • chore: Other changes that don't modify src or test files (no version bump)
  • revert: Reverts a previous commit (no version bump)

Breaking Changes:

To indicate a breaking change (triggers major version bump, e.g., 1.0.0 → 2.0.0), add ! after the type:

feat!: breaking API change
feat(api)!: breaking change in API
fix!: breaking fix

OR use BREAKING CHANGE in footer:

feat: add new feature

BREAKING CHANGE: this changes the API

Examples:

feat: add new greeting function
fix: resolve encoding issue in hello function
feat(api): add support for custom greetings
fix(auth)!: change authentication flow (breaking)
docs: update installation instructions
perf: improve hello function performance

Creating a Release

  1. Ensure all commits since the last release follow the conventional commit format
  2. Go to ActionsSemantic Release
  3. Click "Run workflow"
  4. Select branch (usually main)
  5. Click "Run workflow"

The workflow will automatically:

  • ✅ Analyze commits to determine the version bump (major/minor/patch)
  • ✅ Update version in pyproject.toml and src/test_publish/__init__.py
  • ✅ Generate/update CHANGELOG.md
  • ✅ Create a git commit and tag (e.g., v1.2.3)
  • ✅ Build the package using Poetry
  • ✅ Publish to PyPI
  • ✅ Create a GitHub release with release notes

Pull Request Checks

When you open a PR, the CI will automatically:

  • ✅ Validate that the PR title follows the conventional commit format
  • ✅ Run linters (Black and Ruff)
  • ✅ Execute tests with coverage

Note: Individual commit messages in the PR are NOT validated. This is intentional for a squash merge workflow, where:

  • Feature branch commits can have any format (WIP commits, fixup commits, etc.)
  • Only the PR title matters - it becomes the commit message when squashed
  • semantic-release reads the squashed commit (PR title) from main branch

PR Title Examples:

✅ feat: add user authentication
✅ fix: resolve memory leak in parser
✅ feat(api)!: breaking change to REST API
❌ Added some new features (not conventional format)
❌ WIP: work in progress (not a valid type)

Recommended GitHub Settings

For squash merge workflow, configure your repository:

  1. Go to SettingsGeneralPull Requests
  2. Allow only "Squash and merge"
  3. Disable "Allow merge commits" and "Allow rebase merging"
  4. This ensures the PR title always becomes the commit message

Configuration

PyPI Token

To publish to PyPI, add your PyPI token as a GitHub secret:

  1. Generate a PyPI token at https://pypi.org/manage/account/token/
  2. Add it as PYPI_TOKEN in your repository secrets

Customization

Edit pyproject.toml to customize:

  • Package name
  • Author information
  • Repository URLs
  • Python version constraints
  • Dependencies

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with conventional commits
  4. Push to your fork
  5. Open a Pull Request

The PR checks will automatically validate your commit messages.

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

vmakarevich_test_publish-1.2.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

vmakarevich_test_publish-1.2.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file vmakarevich_test_publish-1.2.1.tar.gz.

File metadata

  • Download URL: vmakarevich_test_publish-1.2.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for vmakarevich_test_publish-1.2.1.tar.gz
Algorithm Hash digest
SHA256 79e0eed4d0c25c443901567f56865283aa74279b1f833bb1bc29223b59566a05
MD5 34bb31c5cf6891b0198c0759dad8cd85
BLAKE2b-256 52c8ec507950554a726c56431cd7a45a9911bd65924f65916386cc42cf909e36

See more details on using hashes here.

File details

Details for the file vmakarevich_test_publish-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for vmakarevich_test_publish-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ceacbf9cdb81ce8838dee06d239f9b18f635b9159e94b2c0471b22e8e4edac64
MD5 70d18979f343a9e2734a055084656fee
BLAKE2b-256 b2fef6f7d7f49ff374368767b3af74e20fb277e7f204129493a438c910771e2d

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