@@ -82,20 +82,34 @@ jobs:
8282 - name : Generate beta version
8383 id : beta_version
8484 run : |
85- # Read current version from setup .py
86- CURRENT_VERSION=$(grep -o '__version__ = "[^"]*"' setup .py | cut -d"" -f2 )
85+ # Read current version from __about__ .py (single source of truth)
86+ CURRENT_VERSION=$(grep -o '__version__ = "[^"]*"' datafog/__about__ .py | sed 's/__version__ = "\(.*\)"/\1/' )
8787 echo "Current version in files: $CURRENT_VERSION"
8888
8989 # Split version into components
90- IFS='.' read -r MAJOR MINOR PATCH_FULL <<< "$CURRENT_VERSION"
90+ IFS='.' read -r MAJOR MINOR PATCH_FULL <<< "$CURRENT_VERSION" || true
91+
92+ # Validate we got valid version components
93+ if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH_FULL" ]]; then
94+ echo "Error: Could not parse version components from $CURRENT_VERSION"
95+ echo "Using default version 0.0.1b1"
96+ MAJOR=0
97+ MINOR=0
98+ PATCH_FULL=1
99+ fi
91100
92101 # Handle beta suffix if it exists
93102 if [[ $PATCH_FULL == *b* ]]; then
94103 # Extract the numeric part before 'b'
95104 PATCH_NUM=${PATCH_FULL%%b*}
96105 # Extract the beta number and increment it
97106 BETA_NUM=${PATCH_FULL#*b}
98- BETA_NUM=$((BETA_NUM + 1))
107+ # Ensure beta number is a valid integer
108+ if ! [[ $BETA_NUM =~ ^[0-9]+$ ]]; then
109+ BETA_NUM=1
110+ else
111+ BETA_NUM=$((BETA_NUM + 1))
112+ fi
99113 else
100114 # If not already a beta, use the patch number and start with beta1
101115 PATCH_NUM=$PATCH_FULL
@@ -107,13 +121,8 @@ jobs:
107121 echo "Generated beta version: $BETA_VERSION"
108122 echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT
109123
110- # Update version in setup.py
111- sed -i "s/__version__ = \"[^\"]*\"/__version__ = \"$BETA_VERSION\"/g" setup.py
112-
113- # Update version in __about__.py if it exists
114- if [ -f "datafog/__about__.py" ]; then
115- sed -i "s/__version__ = \"[^\"]*\"/__version__ = \"$BETA_VERSION\"/g" datafog/__about__.py
116- fi
124+ # Update version in __about__.py (single source of truth)
125+ sed -i "s/__version__ = \"[^\"]*\"/__version__ = \"$BETA_VERSION\"/g" datafog/__about__.py
117126 - name : Build package
118127 run : python -m build
119128 - name : Create GitHub Pre-Release
@@ -125,7 +134,7 @@ jobs:
125134 git config user.email github-actions@github.com
126135
127136 # Commit the version changes
128- git add setup.py datafog/__about__.py
137+ git add datafog/__about__.py
129138 git commit -m "Bump version to $BETA_VERSION [skip ci]"
130139
131140 # Create and push tag
0 commit comments