@@ -23,24 +23,27 @@ jobs:
2323 - name : Auto-increment version
2424 id : version_bump
2525 run : |
26+ # Pull latest changes first (in case version was manually updated)
27+ git pull --rebase origin main || true
28+
2629 # Get current version from pyproject.toml
2730 CURRENT_VERSION=$(grep -Po '(?<=^version = ")[^"]*' pyproject.toml)
28- echo "Current version: $CURRENT_VERSION"
31+ echo "Current version in pyproject.toml : $CURRENT_VERSION"
2932
3033 # Check if this version was already released to PyPI
3134 PYPI_CHECK=$(curl -s https://pypi.org/pypi/hatiyar/json | grep -o "\"$CURRENT_VERSION\"" || echo "not_found")
3235
3336 if [ "$PYPI_CHECK" = "not_found" ]; then
3437 # Version is new, use it as-is
3538 NEW_VERSION="$CURRENT_VERSION"
36- echo "✅ Using version $NEW_VERSION (not on PyPI yet )"
39+ echo "Using version $NEW_VERSION (not found on PyPI, will publish )"
3740 else
3841 # Version exists on PyPI, determine bump type from commit message
3942 COMMIT_MSG="${{ github.event.head_commit.message }}"
4043 IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
4144
42- echo "⚠️ Version $CURRENT_VERSION exists on PyPI"
43- echo "📝 Commit message: $COMMIT_MSG"
45+ echo "Version $CURRENT_VERSION already exists on PyPI"
46+ echo "Commit message: $COMMIT_MSG"
4447
4548 # Determine version bump based on conventional commits
4649 if echo "$COMMIT_MSG" | grep -qiE "^BREAKING CHANGE:|^[a-z]+(\([a-z]+\))?!:"; then
@@ -66,11 +69,14 @@ jobs:
6669 # Update pyproject.toml with new version
6770 sed -i "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
6871
69- # Commit the version bump
72+ # Commit and push the version bump
7073 git config user.name "github-actions[bot]"
7174 git config user.email "github-actions[bot]@users.noreply.github.com"
7275 git add pyproject.toml
7376 git commit -m "chore: auto-bump version to $NEW_VERSION [skip ci]"
77+
78+ # Pull again before pushing to avoid conflicts
79+ git pull --rebase origin main || true
7480 git push
7581 fi
7682
0 commit comments