publish-lib-ghp
A professional Python library demonstrating best practices for packaging and publishing to PyPI using modern tools and automated CI/CD.
🚀 Features
- Professional packaging with Poetry and pyproject.toml
- Automated CI/CD with GitHub Actions
- Comprehensive testing with pytest
- Semantic versioning with automated releases
- Dynamic versioning using importlib.metadata
- Automated release script (
commit.py) for easy publishing - Template ready - Use as base for your own Python packages
- Multiple classes - Greeting and Operations functionality
📦 Installation
pip install publish-lib-ghp
🔧 Usage
from publish_lib_ghp import Greeting, Operations
# Create instances
greeting = Greeting()
operations = Operations()
# Basic greeting functionality
message = greeting.say_hello("World")
print(message) # Output: Hello, World!
# Time-specific greetings
morning_msg = greeting.get_greeting_with_time("Alice", "morning")
print(morning_msg) # Output: Good morning, Alice!
# Say goodbye
goodbye_msg = greeting.say_goodbye("Bob")
print(goodbye_msg) # Output: Goodbye, Bob!
# Mathematical operations
result = operations.add(5, 3)
print(result) # Output: 8
🛠️ Development
Prerequisites
- Python 3.11+
- Poetry
Setup
# Clone the repository
git clone https://github.com/ghpascon/publish_lib_ghp.git
cd publish_lib_ghp
# Install dependencies
poetry install
Testing
# Run all tests
poetry run pytest
# Run specific test file
poetry run pytest tests/test_greeting.py
poetry run pytest tests/test_operations.py
Building
# Build the package
poetry build
# Check the build
poetry run twine check dist/*
📋 API Reference
Greeting Class
say_hello(name: str) -> str
Say hello to someone.
Parameters:
name(str): The name of the person to greet
Returns:
- str: A greeting message
Raises:
- ValueError: If name is empty or not a string
say_goodbye(name: str) -> str
Say goodbye to someone.
Parameters:
name(str): The name of the person to say goodbye to
Returns:
- str: A goodbye message
Raises:
- ValueError: If name is empty or not a string
get_greeting_with_time(name: str, time_of_day: str) -> str
Get a time-specific greeting.
Parameters:
name(str): The name of the person to greettime_of_day(str): Time of day ('morning', 'afternoon', 'evening')
Returns:
- str: A time-specific greeting message
Raises:
- ValueError: If name is invalid or time_of_day is not recognized
Operations Class
add(a: int, b: int) -> int
Perform addition of two integers.
Parameters:
a(int): The first numberb(int): The second number
Returns:
- int: The sum of a and b
Example:
ops = Operations()
result = ops.add(5, 3) # Returns 8
🚀 Release Process
This project uses automated releases via GitHub Actions. Use the included commit.py script for easy releases!
Automated Release (Recommended)
# Use the automated script
python commit.py
The script will:
- Ask for version type (patch, minor, major)
- Ask for commit message
- Update version automatically
- Commit and create tag
- Trigger GitHub Actions to publish
Manual Release
# Update version
poetry version patch # or minor/major
# Commit and tag
git add .
git commit -m "Your commit message"
git push origin main
git tag "v$(poetry version --short)"
git push origin "v$(poetry version --short)"
The CI/CD pipeline will automatically:
- Run tests across multiple Python versions (3.11, 3.12, 3.13)
- Build the package
- Publish to PyPI
📝 Documentation
- Setup Guide - How to use this project as a template
- Release Process - How to create and publish releases
- Publishing Guide - Comprehensive guide for package publishing
- PyPI Setup - PyPI configuration instructions
- Contributing - How to contribute to this project
- Security Policy - Security guidelines and reporting
- Changelog - Project history and changes
🏗️ Project Structure
publish_lib_ghp/
├── .github/
│ └── workflows/ # GitHub Actions CI/CD pipelines
├── src/
│ └── publish_lib_ghp/ # Main package code
│ ├── __init__.py # Package initialization
│ ├── greeting.py # Greeting functionality
│ └── operations.py # Mathematical operations
├── tests/ # Test suite
│ ├── test_greeting.py # Tests for Greeting class
│ └── test_operations.py # Tests for Operations class
├── commit.py # Automated release script
├── pyproject.toml # Project configuration
├── README.md # This file
├── SETUP_GUIDE.md # Template usage guide
├── CHANGELOG.md # Version history
└── LICENSE # MIT License
🔐 Security
This project follows security best practices:
- ✅ No hardcoded secrets or API tokens
- ✅ Secure publishing to PyPI via GitHub Actions
- ✅ Automated testing across multiple Python versions
- ✅ Clean and minimal dependencies
See our Security Policy for details.
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Quick Start
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
poetry run pytest - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
🎯 Using as Template
Want to create your own Python package? See SETUP_GUIDE.md for step-by-step instructions on how to use this project as a template.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Poetry for modern Python packaging
- GitHub Actions for CI/CD
- PyPI for package distribution
- pytest for testing framework
📊 Project Status
- ✅ Active Development: This project is actively maintained
- ✅ Production Ready: Suitable for production use
- ✅ Well Tested: Comprehensive test coverage
- ✅ Documented: Complete documentation available
- ✅ Secure: Follows security best practices
Author: Gabriel Henrique Pascon
Email: gh.pascon@gmail.com
GitHub: @ghpascon
Metadata
Release files for publish-lib-example 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| publish_lib_example-1.1.1.tar.gz | 5.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| publish_lib_example-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / publish_lib_example-1.1.1.tar.gz
| Download URL | publish_lib_example-1.1.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5dea253b40385cd4d03d67b6fc87a7122edc636a103930f882b69a2009ecfc80
|
|
BLAKE2b-256 checksum How to use checksums |
8c899dd79815509652ec868e6687ad2a1415fbef6c7a76aaefe72ed9dde2aabb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / publish_lib_example-1.1.1-py3-none-any.whl
| Download URL | publish_lib_example-1.1.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e809d755e8619cb680b5d742cdd911390a377a1cc2e4a0e2b1c7a7cbfb957ff
|
|
BLAKE2b-256 checksum How to use checksums |
5f9daa328abf3c3a3fc6278ba3a681be8c39a49cf8e080c1974981d72f0820ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for publish-lib-example 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.