Diese Dokumentation beschreibt das moderne Python CI/CD System mit automatischem Semantic Versioning und PyPI Publishing.
Das Python System bietet zwei spezialisierte Workflows:
python-build.yml- Für Anwendungen (Django, FastAPI, ML, CLI-Tools)python-semantic-release.yml- Für Packages (PyPI Publishing mit Semantic Versioning)
Für Python-Anwendungen ohne PyPI Publishing.
- ✅ Multi-Python Version Support (3.8-3.13)
- ✅ Intelligente Dependency-Erkennung (pip, poetry, pipenv)
- ✅ Umfassende Tests (pytest, unittest, coverage)
- ✅ Code Quality (ruff, bandit, safety)
- ✅ Security Scanning
- ✅ Docker Integration
- ✅ Artifact Generation
jobs:
python-ci:
uses: bauer-group/automation-templates/.github/workflows/python-build.yml@main
with:
python-version: '3.12'
run-tests: true
collect-coverage: true
run-security-scan: true
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}Für Python-Packages mit automatischem Semantic Versioning und PyPI Publishing.
- ✅ Semantic Versioning - Automatische Versionierung basierend auf Conventional Commits
- ✅ Trusted Publishing - Sichere PyPI-Authentifizierung ohne API-Token
- ✅ Changelog Generation - Automatische CHANGELOG.md Erstellung
- ✅ GitHub Releases - Automatische Release-Erstellung
- ✅ Multi-File Versioning - Synchronisation von pyproject.toml und init.py
- ✅ Umfassende Tests - Quality Gates vor Release
- ✅ Security Scanning - Sicherheitsprüfungen
- ✅ Wheel Testing - Lokale Package-Installation Tests
- ✅ Documentation Updates - Automatische Dokumentation nach Release
jobs:
python-release:
uses: bauer-group/automation-templates/.github/workflows/python-semantic-release.yml@main
with:
python-version: '3.12'
run-tests: true
build-local-wheel: true
skip-pypi: false
update-documentation: true
update-security-policy: true
secrets: inherit[tool.semantic_release]
# Version management
version_toml = ["pyproject.toml:project.version"]
version_variables = [
"src/your_package/__init__.py:__version__",
]
# Git & Release configuration
branch = "main"
build_command = "python -m build"
upload_to_vcs_release = true
# Changelog configuration
changelog_file = "CHANGELOG.md"
changelog_sections = [
{section = "breaking", name = "Breaking Changes"},
{section = "feat", name = "Features"},
{section = "fix", name = "Bug Fixes"},
{section = "perf", name = "Performance Improvements"},
{section = "refactor", name = "Code Refactoring"},
{section = "style", name = "Code Style"},
{section = "build", name = "Build System"},
{section = "docs", name = "Documentation"},
{section = "test", name = "Tests"},
{section = "ci", name = "CI/CD"},
{section = "chore", name = "Chores"},
{section = "revert", name = "Reverts"},
]
# Commit parsing
commit_parser = "conventional"
[tool.semantic_release.commit_parser_options]
allowed_tags = ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore", "ci", "build", "revert"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]- Major (X.0.0):
feat!:oderfix!:oderBREAKING CHANGE: - Minor (0.X.0):
feat: - Patch (0.0.X):
fix:,perf:
docs:- Dokumentationstyle:- Code-Formatierungrefactor:- Code-Umstrukturierungtest:- Testsci:- CI/CDchore:- Wartungbuild:- Build-Systemrevert:- Rückgängig machen
- Gehe zu https://pypi.org/manage/account/publishing/
- Füge "pending publisher" hinzu:
- PyPI project name:
your-package-name - Owner:
your-github-username - Repository:
your-repo-name - Workflow name:
release.yml - Environment: (leer lassen)
- PyPI project name:
on:
push:
branches: [main]
paths-ignore:
- '*.md'
- 'docs/**'your-repo/
├── src/your_package/
│ ├── __init__.py # __version__ = "1.0.0"
│ └── main.py
├── tests/
│ └── test_*.py
├── pyproject.toml # Semantic release config
├── README.md
├── CHANGELOG.md # Auto-generiert
└── .github/workflows/
└── release.yml # Dein Workflow
Siehe examples/python-semantic-release-example.yml
Siehe examples/pyproject.toml
- uses: bauer-group/automation-templates/.github/workflows/python-automatic-release.yml@main
+ uses: bauer-group/automation-templates/.github/workflows/python-semantic-release.yml@main- uses: bauer-group/automation-templates/.github/workflows/python-publish.yml@main
+ uses: bauer-group/automation-templates/.github/workflows/python-semantic-release.yml@main
with:
- registry: 'pypi'
+ skip-pypi: false
secrets: inherit- ✅ Moderne Architektur - python-semantic-release (2024 Standard)
- ✅ Automatisches Versioning - Basierend auf Commit-Messages
- ✅ Sicheres Publishing - Trusted Publishing ohne API-Token
- ✅ Vollständige Integration - Tests, Security, Docs, alles in einem
- ✅ Bessere Performance - Weniger Workflow-Overhead
- ✅ Professionelle Changelogs - Strukturiert und automatisch
| Input | Description | Default | Options |
|---|---|---|---|
runs-on |
Runner to use | ubuntu-latest |
String or JSON array (see below) |
The runs-on parameter supports both GitHub-hosted and self-hosted runners:
# GitHub-hosted (string)
runs-on: 'ubuntu-latest'
# Self-hosted (JSON array)
runs-on: '["self-hosted", "linux"]'
runs-on: '["self-hosted", "linux", "docker"]'See Self-Hosted Runner Documentation for details.
Für Fragen und Probleme: