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
- Install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
- 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
- Install Python dependencies:
poetry install
- Install Node.js dependencies:
npm install
- 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
- Ensure all commits since the last release follow the conventional commit format
- Go to Actions → Semantic Release
- Click "Run workflow"
- Select branch (usually
main) - Click "Run workflow"
The workflow will automatically:
- ✅ Analyze commits to determine the version bump (major/minor/patch)
- ✅ Update version in
pyproject.tomlandsrc/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:
- Go to Settings → General → Pull Requests
- Allow only "Squash and merge"
- Disable "Allow merge commits" and "Allow rebase merging"
- 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:
- Generate a PyPI token at https://pypi.org/manage/account/token/
- Add it as
PYPI_TOKENin 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
- Fork the repository
- Create a feature branch
- Make your changes with conventional commits
- Push to your fork
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vmakarevich_test_publish-1.2.0.tar.gz.
File metadata
- Download URL: vmakarevich_test_publish-1.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb00df7b80445bedef807cad218d8dd93ba147cb65ad09f64902f5e2f597c9f0
|
|
| MD5 |
00de6090a19fc6550275991e7e8c6fc8
|
|
| BLAKE2b-256 |
2ceb1190d901eb218872940975f82ad24993cd6514a03a69402157cd24559543
|
File details
Details for the file vmakarevich_test_publish-1.2.0-py3-none-any.whl.
File metadata
- Download URL: vmakarevich_test_publish-1.2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
383dba7824e7ec7cdf90656fd16aee3ce844b8cb6917796ee08d34b158ff322c
|
|
| MD5 |
f87ba12ec9e967bbc457ff988f443112
|
|
| BLAKE2b-256 |
a1131acac23f2f9fa1e7fbe131306a2625f9d56bac400880edbb361615989f47
|