@@ -82,22 +82,38 @@ jobs:
82
82
- name : Generate beta version
83
83
id : beta_version
84
84
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
+
89
89
# 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"
97
107
echo "Generated beta version: $BETA_VERSION"
98
108
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
101
117
- name : Build package
102
118
run : python -m build
103
119
- name : Create GitHub Pre-Release
@@ -107,8 +123,19 @@ jobs:
107
123
run : |
108
124
git config user.name github-actions
109
125
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
110
132
git tag v$BETA_VERSION
133
+
134
+ # Push both the commit and the tag
135
+ git push origin HEAD:dev
111
136
git push origin v$BETA_VERSION
137
+
138
+ # Create GitHub release
112
139
gh release create v$BETA_VERSION --prerelease --title "Beta Release v$BETA_VERSION" --notes "Automated beta release from dev branch"
113
140
- name : Publish to PyPI as Beta
114
141
env :
0 commit comments