A professional Python library demonstrating best practices for packaging and publishing to PyPI using modern tools and automated CI/CD.
- 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
pip install publish-lib-ghpfrom 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- Python 3.11+
- Poetry
# Clone the repository
git clone https://github.com/ghpascon/publish_lib_ghp.git
cd publish_lib_ghp
# Install dependencies
poetry install# Run all tests
poetry run pytest
# Run specific test file
poetry run pytest tests/test_greeting.py
poetry run pytest tests/test_operations.py# Build the package
poetry build
# Check the build
poetry run twine check dist/*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 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 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
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 8This project uses automated releases via GitHub Actions. Use the included commit.py script for easy releases!
# Use the automated script
python commit.pyThe 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
# 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
- 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
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
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.
We welcome contributions! Please see our Contributing Guide for details.
- 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
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.
This project is licensed under the MIT License - see the LICENSE file for details.
- Poetry for modern Python packaging
- GitHub Actions for CI/CD
- PyPI for package distribution
- pytest for testing framework
- β 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