@@ -62,21 +62,50 @@ jobs:
6262 - name : Determine version bump type
6363 id : version
6464 run : |
65- # Extract current version from pyproject.toml
66- current_version=$(grep -E '^version = "' pyproject.toml | cut -d'"' -f2)
65+ # Extract current version from __init__.py
66+ current_version=$(grep -E '^__version__ = "' src/sprout/__init__.py | cut -d'"' -f2)
6767 echo "Current version: $current_version"
6868
6969 # Analyze changelog to determine bump type
70- major_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Removed)" || true)
71- minor_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Added|Changed|Deprecated)" || true)
72- patch_changes=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -E "^### (Fixed|Security)" || true)
70+ # Extract the Unreleased section
71+ unreleased_section=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md)
7372
74- # Determine bump type (check in order: major -> minor -> patch)
75- if [ -n "$major_changes" ]; then
73+ # Check for sections with actual entries (lines starting with -)
74+ major_entries=""
75+ minor_entries=""
76+ patch_entries=""
77+
78+ # Check if Removed section has entries
79+ if echo "$unreleased_section" | grep -q "^### Removed"; then
80+ major_entries=$(echo "$unreleased_section" | sed -n '/### Removed/,/^###\|^##/p' | grep "^- " || true)
81+ fi
82+
83+ # Check if Added/Changed/Deprecated sections have entries
84+ for section in "Added" "Changed" "Deprecated"; do
85+ if echo "$unreleased_section" | grep -q "^### $section"; then
86+ section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true)
87+ if [ -n "$section_entries" ]; then
88+ minor_entries="$minor_entries$section_entries"
89+ fi
90+ fi
91+ done
92+
93+ # Check if Fixed/Security sections have entries
94+ for section in "Fixed" "Security"; do
95+ if echo "$unreleased_section" | grep -q "^### $section"; then
96+ section_entries=$(echo "$unreleased_section" | sed -n "/### $section/,/^###\|^##/p" | grep "^- " || true)
97+ if [ -n "$section_entries" ]; then
98+ patch_entries="$patch_entries$section_entries"
99+ fi
100+ fi
101+ done
102+
103+ # Determine bump type based on actual entries
104+ if [ -n "$major_entries" ]; then
76105 bump_type="major"
77- elif [ -n "$minor_changes " ]; then
106+ elif [ -n "$minor_entries " ]; then
78107 bump_type="minor"
79- elif [ -n "$patch_changes " ]; then
108+ elif [ -n "$patch_entries " ]; then
80109 bump_type="patch"
81110 else
82111 # Default to patch if only individual items without category
@@ -180,10 +209,7 @@ jobs:
180209
181210 - name : Update version in files
182211 run : |
183- # Update pyproject.toml
184- sed -i 's/version = ".*"/version = "${{ needs.prepare-release.outputs.version }}"/' pyproject.toml
185-
186- # Update __init__.py
212+ # Update __init__.py (pyproject.toml reads version from here dynamically)
187213 sed -i 's/__version__ = ".*"/__version__ = "${{ needs.prepare-release.outputs.version }}"/' src/sprout/__init__.py
188214
189215 # Update CHANGELOG.md
@@ -199,7 +225,7 @@ jobs:
199225 run : |
200226 git config --local user.email "action@github.com"
201227 git config --local user.name "GitHub Action"
202- git add pyproject.toml src/sprout/__init__.py CHANGELOG.md
228+ git add src/sprout/__init__.py CHANGELOG.md
203229 git commit -m "Release version ${{ needs.prepare-release.outputs.version }}"
204230
205231 - name : Build package
0 commit comments