diff --git a/.github/workflows/auto-version.yml b/.github/workflows/auto-version.yml index 2b8dde8..d522647 100644 --- a/.github/workflows/auto-version.yml +++ b/.github/workflows/auto-version.yml @@ -1,8 +1,7 @@ name: Auto Versioning on: - pull_request: - types: [closed] + push: branches: - master @@ -11,29 +10,22 @@ permissions: jobs: bump-version: - if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - ref: master - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - - name: Bump version - id: bump - run: python scripts/bump_version.py - - name: Generate Changelog uses: orhun/git-cliff-action@v4 with: config: cliff.toml - args: --tag v${{ steps.bump.outputs.new_version }} outputPath: CHANGELOG.md - name: Sync Changelogs @@ -44,23 +36,15 @@ jobs: fi done - - name: Commit and Tag + - name: Stage changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" + git add CHANGELOG.md docs/en/CHANGELOG.md docs/de/CHANGELOG.md - # Add modified files, ignore those that don't exist - FILES="pyproject.toml pyadm1/__version__.py tests/__init__.py CHANGELOG.md docs/en/metrics.md docs/de/metrics.md docs/en/CHANGELOG.md docs/de/CHANGELOG.md" - for f in $FILES; do - if [ -f "$f" ]; then - git add "$f" - fi - done - - if ! git diff --cached --quiet; then - git commit -m "chore(release): bump version to ${{ steps.bump.outputs.new_version }} [skip ci]" - git tag -a v${{ steps.bump.outputs.new_version }} -m "Release v${{ steps.bump.outputs.new_version }}" - git push origin master --tags - else - echo "No changes to commit" - fi + - name: Auto Version and Badges + uses: dgaida/auto-version-action@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + auto-version: true + create-badge: true diff --git a/docs/de/metrics.md b/docs/de/metrics.md index 68886f5..0c80fe0 100644 --- a/docs/de/metrics.md +++ b/docs/de/metrics.md @@ -10,10 +10,10 @@ Aktuelle Abdeckung: **98.1%** (Ziel: 95%) | Modul | Abdeckung | |-------|-----------| -| `pyadm1.core` | 98.1% | -| `pyadm1.components` | 98.5% | -| `pyadm1.simulation` | 100.0% | -| `pyadm1.configurator` | 98.2% | +| \`pyadm1.core\` | 98.1% | +| \`pyadm1.components\` | 98.5% | +| \`pyadm1.simulation\` | 100.0% | +| \`pyadm1.configurator\` | 98.2% | ## Build-Status @@ -24,5 +24,4 @@ Aktuelle Abdeckung: **98.1%** (Ziel: 95%) ## Wartung -- **Changelog**: Aktuell (v0.1.3) -- **Zuletzt aktualisiert**: 07.04.2026 +Bitte beachten Sie die [Haupt-README](../../README.md) für die aktuelle Version und den Wartungsstatus. diff --git a/docs/en/metrics.md b/docs/en/metrics.md index e62a127..63f3548 100644 --- a/docs/en/metrics.md +++ b/docs/en/metrics.md @@ -10,10 +10,10 @@ Current coverage: **98.1%** (Target: 95%) | Module | Coverage | |--------|----------| -| `pyadm1.core` | 98.1% | -| `pyadm1.components` | 98.5% | -| `pyadm1.simulation` | 100.0% | -| `pyadm1.configurator` | 98.2% | +| \`pyadm1.core\` | 98.1% | +| \`pyadm1.components\` | 98.5% | +| \`pyadm1.simulation\` | 100.0% | +| \`pyadm1.configurator\` | 98.2% | ## Build Status @@ -24,5 +24,4 @@ Current coverage: **98.1%** (Target: 95%) ## Maintenance -- **Changelog**: Up to date (v0.1.3) -- **Last Updated**: 2026-04-07 +Please see the [main README](../../README.md) for the latest version and maintenance status. diff --git a/pyadm1/__init__.py b/pyadm1/__init__.py index e8fc70a..1c3dc71 100644 --- a/pyadm1/__init__.py +++ b/pyadm1/__init__.py @@ -26,7 +26,17 @@ >>> results = plant.simulate(duration=30, dt=1/24) """ -from pyadm1.__version__ import __version__ +try: + from importlib.metadata import version, PackageNotFoundError +except ImportError: # pragma: no cover + # For Python < 3.8 + from importlib_metadata import version, PackageNotFoundError # type: ignore + +try: + __version__ = version("pyadm1") +except PackageNotFoundError: # pragma: no cover + # package is not installed + __version__ = "unknown" # Core imports from .configurator import BiogasPlant diff --git a/pyadm1/__version__.py b/pyadm1/__version__.py deleted file mode 100644 index 0ec7748..0000000 --- a/pyadm1/__version__.py +++ /dev/null @@ -1,9 +0,0 @@ -# ============================================================================ -# pyadm1/__version__.py -# ============================================================================ -"""Version information for PyADM1.""" - -__version__ = "0.1.3" -__author__ = "Daniel Gaida" -__email__ = "daniel.gaida@th-koeln.de" -__license__ = "MIT" diff --git a/scripts/bump_version.py b/scripts/bump_version.py deleted file mode 100644 index 85236e3..0000000 --- a/scripts/bump_version.py +++ /dev/null @@ -1,111 +0,0 @@ -import os -import re -import sys -from datetime import date - - -def bump_version(current_version): - parts = current_version.split(".") - if len(parts) != 3: - raise ValueError(f"Invalid version format: {current_version}") - major, minor, patch = map(int, parts) - patch += 1 - return f"{major}.{minor}.{patch}" - - -def update_file(filepath, pattern, replacement, flags=0): - if not os.path.exists(filepath): - print(f"Warning: {filepath} not found.") - return - with open(filepath, "r", encoding="utf-8") as f: - content = f.read() - - new_content, count = re.subn(pattern, replacement, content, flags=flags) - if count == 0: - print(f"Warning: No matches found for pattern in {filepath}") - else: - with open(filepath, "w", encoding="utf-8") as f: - f.write(new_content) - print(f"Updated {filepath} ({count} replacements)") - - -def main(): - pyproject_path = "pyproject.toml" - if not os.path.exists(pyproject_path): - print(f"Error: {pyproject_path} not found.") - sys.exit(1) - - with open(pyproject_path, "r", encoding="utf-8") as f: - content = f.read() - - # Specifically look for version in [project] section - match = re.search(r'\[project\]\n(?:.*\n)*?version\s*=\s*"([^"]*)"', content) - if not match: - # Fallback to general search if section not found exactly as expected - match = re.search(r'^version\s*=\s*"([^"]*)"', content, re.MULTILINE) - - if not match: - print("Error: Could not find version in pyproject.toml") - sys.exit(1) - - current_version = match.group(1) - new_version = bump_version(current_version) - today_iso = date.today().isoformat() - today_german = date.today().strftime("%d.%m.%Y") - - print(f"Bumping version: {current_version} -> {new_version}") - - # pyproject.toml: only update version in [project] section - update_file( - "pyproject.toml", - r'(\[project\]\n(?:.*\n)*?version\s*=\s*)"[^"]*"', - r'\g<1>"' + new_version + '"', - ) - - # Other files - updates = [ - ( - "pyadm1/__version__.py", - r'(__version__\s*=\s*)"[^"]*"', - r'\g<1>"' + new_version + '"', - ), - ( - "tests/__init__.py", - r'(__version__\s*=\s*)"[^"]*"', - r'\g<1>"' + new_version + '"', - ), - ( - "docs/en/metrics.md", - r"(\*\*Changelog\*\*:\s*Up to date \(v)[^)]*(\))", - r"\g<1>" + new_version + r"\g<2>", - ), - ( - "docs/en/metrics.md", - r"(\*\*Last Updated\*\*:\s*)\d{4}-\d{2}-\d{2}", - r"\g<1>" + today_iso, - ), - ( - "docs/de/metrics.md", - r"(\*\*Changelog\*\*:\s*Aktuell \(v)[^)]*(\))", - r"\g<1>" + new_version + r"\g<2>", - ), - ( - "docs/de/metrics.md", - r"(\*\*Zuletzt aktualisiert\*\*:\s*)\d{2}\.\d{2}\.\d{4}", - r"\g<1>" + today_german, - ), - ] - - for filepath, pattern, replacement in updates: - update_file(filepath, pattern, replacement) - - github_output = os.environ.get("GITHUB_OUTPUT") - if github_output: - with open(github_output, "a") as f: - f.write(f"new_version={new_version}\n") - - print(f"Successfully bumped version to {new_version}") - - -if __name__ == "__main__": - main() diff --git a/tests/__init__.py b/tests/__init__.py index c410be7..fc387b8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,5 +4,3 @@ This package contains unit tests for the PyADM1 implementation of the Anaerobic Digestion Model No. 1. """ - -__version__ = "0.1.3"