@@ -69,24 +69,40 @@ jobs:
6969 if : steps.set_mode.outputs.is_dry_run == 'true' && steps.release_dryrun.outputs.version == ''
7070 shell : bash
7171 run : |
72- # Get output from the action logs
73- VERSION_LINE=$(cat $GITHUB_STEP_SUMMARY | grep -o "New version will be.*")
74- echo "Log line: $VERSION_LINE"
75-
76- # Extract the version number
77- if [[ $VERSION_LINE =~ New\ version\ will\ be\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
78- NEXT_VERSION="${BASH_REMATCH[1]}"
79- echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
80- echo "next_tag=v$NEXT_VERSION" >> $GITHUB_OUTPUT
81- echo "Found next version: $NEXT_VERSION"
72+ # When no release is needed, semantic-release doesn't output the next version
73+ # We need to determine it manually from the commit history
74+
75+ # Check if we have commits that would trigger a version bump
76+ FEAT_COMMITS=$(git log --grep="^feat:" -i --pretty=format:"%h" | wc -l)
77+ FIX_COMMITS=$(git log --grep="^fix:" -i --pretty=format:"%h" | wc -l)
78+ BREAKING_COMMITS=$(git log --grep="BREAKING CHANGE:" -i --pretty=format:"%h" | wc -l)
79+
80+ # Get current version from pyproject.toml
81+ CURRENT_VERSION=$(grep -m 1 'version = "' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^v//')
82+ echo "Current version: $CURRENT_VERSION"
83+
84+ # Split current version into components
85+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
86+
87+ # Determine the next version based on conventional commits
88+ if [ "$BREAKING_COMMITS" -gt 0 ]; then
89+ # Major version bump
90+ NEXT_VERSION="$((MAJOR + 1)).0.0"
91+ elif [ "$FEAT_COMMITS" -gt 0 ]; then
92+ # Minor version bump
93+ NEXT_VERSION="$MAJOR.$((MINOR + 1)).0"
94+ elif [ "$FIX_COMMITS" -gt 0 ]; then
95+ # Patch version bump
96+ NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
8297 else
83- # Fallback to current version
84- CURRENT_VERSION=$(grep -m 1 'version = "' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^v//')
85- echo "next_version=${CURRENT_VERSION}.dev0" >> $GITHUB_OUTPUT
86- echo "next_tag=v${CURRENT_VERSION}.dev0" >> $GITHUB_OUTPUT
87- echo "Using current version with dev suffix: ${CURRENT_VERSION}.dev0"
98+ # No significant changes, use development version
99+ NEXT_VERSION="${CURRENT_VERSION}.dev0"
88100 fi
89101
102+ echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
103+ echo "next_tag=v$NEXT_VERSION" >> $GITHUB_OUTPUT
104+ echo "Determined next version: $NEXT_VERSION"
105+
90106 - name : Python Release
91107 id : release
92108 if : ${{ github.event_name == 'workflow_dispatch' && !inputs.dry_run }}
0 commit comments