diff --git a/.github/workflows/update-code-version.yml b/.github/workflows/update-code-version.yml deleted file mode 100644 index 91ba7819..00000000 --- a/.github/workflows/update-code-version.yml +++ /dev/null @@ -1,40 +0,0 @@ -# @format - -name: Update Version - -on: - push: - tags: - - "v*" - -jobs: - update-version: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Extract version from tag - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - - name: Fetch all branches - run: git fetch --all - - - name: Select main branch - run: git checkout origin/main - - - name: Update version in pyproject.toml - run: | - sed -i "s/version = \".*\"/version = \"$VERSION\"/" pyproject.toml - - - name: Update version in robusta_krr/__init__.py - run: | - sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" robusta_krr/__init__.py - - - name: Commit and push - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add pyproject.toml robusta_krr/__init__.py - git commit -m "Update version to $VERSION" && git push diff --git a/README.md b/README.md index fabdeda0..fa55cb58 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ _View instructions for: [Seeing recommendations in a UI](#free-ui-for-krr-recomm - **No Agent Required**: Run a CLI tool on your local machine for immediate results. (Or run in-cluster for weekly [Slack reports](#slack-integration).) - **Prometheus Integration**: Get recommendations based on the data you already have -- **Explainability**: Understand how recommendations were calculated +- **Explainability**: [Understand how recommendations were calculated with explanation graphs](#free-krr-ui-on-robusta-saas) - **Extensible Strategies**: Easily create and use your own strategies for calculating resource recommendations. - **Free SaaS Platform**: See why KRR recommends what it does, by using the [free Robusta SaaS platform](https://platform.robusta.dev/signup/?utm_source=github&utm_medium=krr-readme). - **Future Support**: Upcoming versions will support custom resources (e.g. GPUs) and custom metrics. @@ -109,7 +109,7 @@ Read more about [how KRR works](#how-krr-works) | Immediate Results ⚡ | ✅ Gets results immediately (given Prometheus is running) | ❌ Requires time to gather data and provide recommendations | | Reporting 📊 | ✅ Json, CSV, Markdown, [Web UI](#free-ui-for-krr-recommendations), and more! | ❌ Not supported | | Extensibility 🔧 | ✅ Add your own strategies with few lines of Python | :warning: Limited extensibility | -| Explainability 📖 | ✅ See graphs explaining the recommendations | ❌ Not supported | +| Explainability 📖 | ✅ [See graphs explaining the recommendations](#free-krr-ui-on-robusta-saas) | ❌ Not supported | | Custom Metrics 📏 | 🔄 Support in future versions | ❌ Not supported | | Custom Resources 🎛️ | 🔄 Support in future versions (e.g., GPU) | ❌ Not supported | | Autoscaling 🔀 | 🔄 Support in future versions | ✅ Automatic application of recommendations | diff --git a/robusta_krr/__init__.py b/robusta_krr/__init__.py index 4866168b..c428657b 100644 --- a/robusta_krr/__init__.py +++ b/robusta_krr/__init__.py @@ -1,4 +1,4 @@ from .main import run -__version__ = "1.8.2-dev" +__version__ = "dev" __all__ = ["run", "__version__"] diff --git a/robusta_krr/utils/version.py b/robusta_krr/utils/version.py index d7b5df7f..47f81c55 100644 --- a/robusta_krr/utils/version.py +++ b/robusta_krr/utils/version.py @@ -1,12 +1,36 @@ -import robusta_krr -import requests import asyncio -from typing import Optional +import os +import subprocess +import sys from concurrent.futures import ThreadPoolExecutor +from typing import Optional + +import requests + +import robusta_krr def get_version() -> str: - return robusta_krr.__version__ + # the version string was patched by a release - return __version__ which will be correct + if robusta_krr.__version__ != "dev": + return robusta_krr.__version__ + + # we are running from an unreleased dev version + try: + # Get the latest git tag + tag = subprocess.check_output(["git", "describe", "--tags"]).decode().strip() + + # Get the current branch name + branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode().strip() + + # Check if there are uncommitted changes + status = subprocess.check_output(["git", "status", "--porcelain"]).decode().strip() + dirty = "-dirty" if status else "" + + return f"{tag}-{branch}{dirty}" + + except Exception: + return robusta_krr.__version__ # Synchronous function to fetch the latest release version from GitHub API