Skip to content

Commit

Permalink
Fix version command on dev builds (#291)
Browse files Browse the repository at this point in the history
* Remove broken workflow for bumping version

* Make version correct on dev builds
  • Loading branch information
aantn authored Jun 15, 2024
1 parent c9f89f5 commit 9465cd9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 45 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/update-code-version.yml

This file was deleted.

2 changes: 1 addition & 1 deletion robusta_krr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .main import run

__version__ = "1.8.2-dev"
__version__ = "dev"
__all__ = ["run", "__version__"]
32 changes: 28 additions & 4 deletions robusta_krr/utils/version.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 9465cd9

Please sign in to comment.