Skip to content

Commit

Permalink
Update setup.py to dynamically retrieve version from git tags and CI …
Browse files Browse the repository at this point in the history
…environment, with fallback options
  • Loading branch information
Maralai committed Dec 15, 2024
1 parent a858c46 commit 3b72b0c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
import setuptools
from setuptools import setup
import os
Expand All @@ -8,10 +9,23 @@

# Get version from git tag with fallback
def get_version():
# First try: Get version from git tag
try:
# Get the latest tag using git describe
version = subprocess.check_output(['git', 'describe', '--tags']).decode().strip()
if version.startswith('v'):
version = version.lstrip('v')
return version
except:
pass

# Second try: Get version from GITHUB_REF_NAME (CI environment)
version = os.environ.get('GITHUB_REF_NAME')
if version and version.startswith('v'):
return version.lstrip('v')
return '0.0.0' # fallback version

# Fallback: Read from version file or use default
return '1.3' # final fallback version

setup(
name="SummarizeGPT",
Expand Down

0 comments on commit 3b72b0c

Please sign in to comment.