@@ -82,22 +82,38 @@ jobs:
8282 - name : Generate beta version
8383 id : beta_version
8484 run : |
85- # Get the latest tag
86- LATEST_TAG =$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0" )
87- # Remove the 'v' prefix if present
88- LATEST_VERSION=${LATEST_TAG#v}
85+ # Read current version from setup.py
86+ CURRENT_VERSION =$(grep -o '__version__ = "[^"]*"' setup.py | cut -d"" -f2 )
87+ echo "Current version in files: $CURRENT_VERSION"
88+
8989 # Split version into components
90- IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
91- # Extract any existing beta suffix
92- PATCH_NUM=${PATCH%%b*}
93- # Get commit count since last tag for unique beta number
94- COMMIT_COUNT=$(git rev-list --count $LATEST_TAG..HEAD 2>/dev/null || echo "1")
95- # Generate beta version
96- BETA_VERSION="$MAJOR.$MINOR.$(($PATCH_NUM))b$COMMIT_COUNT"
90+ IFS='.' read -r MAJOR MINOR PATCH_FULL <<< "$CURRENT_VERSION"
91+
92+ # Handle beta suffix if it exists
93+ if [[ $PATCH_FULL == *b* ]]; then
94+ # Extract the numeric part before 'b'
95+ PATCH_NUM=${PATCH_FULL%%b*}
96+ # Extract the beta number and increment it
97+ BETA_NUM=${PATCH_FULL#*b}
98+ BETA_NUM=$((BETA_NUM + 1))
99+ else
100+ # If not already a beta, use the patch number and start with beta1
101+ PATCH_NUM=$PATCH_FULL
102+ BETA_NUM=1
103+ fi
104+
105+ # Generate new beta version
106+ BETA_VERSION="$MAJOR.$MINOR.${PATCH_NUM}b$BETA_NUM"
97107 echo "Generated beta version: $BETA_VERSION"
98108 echo "version=$BETA_VERSION" >> $GITHUB_OUTPUT
99- # Update version in setup.py or pyproject.toml if needed
100- # This depends on how your versioning is configured
109+
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
101117 - name : Build package
102118 run : python -m build
103119 - name : Create GitHub Pre-Release
@@ -107,8 +123,19 @@ jobs:
107123 run : |
108124 git config user.name github-actions
109125 git config user.email github-actions@github.com
126+
127+ # Commit the version changes
128+ git add setup.py datafog/__about__.py
129+ git commit -m "Bump version to $BETA_VERSION [skip ci]"
130+
131+ # Create and push tag
110132 git tag v$BETA_VERSION
133+
134+ # Push both the commit and the tag
135+ git push origin HEAD:dev
111136 git push origin v$BETA_VERSION
137+
138+ # Create GitHub release
112139 gh release create v$BETA_VERSION --prerelease --title "Beta Release v$BETA_VERSION" --notes "Automated beta release from dev branch"
113140 - name : Publish to PyPI as Beta
114141 env :
0 commit comments