@@ -25,28 +25,52 @@ jobs:
2525 - name : Calculate next version
2626 id : version
2727 run : |
28- # Get the latest tag
29- latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.2.6")
30- echo "Latest tag: $latest_tag"
28+ # Try to extract version from PR title first
29+ pr_title=""
30+ if [ "${{ github.event_name }}" == "push" ]; then
31+ # Get the PR title from the merge commit message
32+ commit_message=$(git log -1 --format='%s')
33+ echo "Commit message: $commit_message"
34+
35+ # Extract version from PR title pattern "chore: 🐝 Update SDK - Generate X.X.X"
36+ if [[ $commit_message =~ Generate\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
37+ extracted_version="${BASH_REMATCH[1]}"
38+ new_version="v$extracted_version"
39+ echo "Extracted version from PR title: $new_version"
40+ else
41+ echo "Could not extract version from commit message, falling back to auto-increment"
42+ extracted_version=""
43+ fi
44+ fi
3145
32- # If set_version is provided , use that
46+ # If manual dispatch with set_version , use that
3347 if [ -n "${{ github.event.inputs.set_version }}" ]; then
3448 new_version="${{ github.event.inputs.set_version }}"
3549 # Add 'v' prefix if not present
3650 if [[ ! $new_version =~ ^v ]]; then
3751 new_version="v$new_version"
3852 fi
53+ echo "Using manual version: $new_version"
54+ # If we extracted version from PR title, use that
55+ elif [ -n "$extracted_version" ]; then
56+ new_version="v$extracted_version"
57+ echo "Using extracted version: $new_version"
3958 else
59+ # Fall back to auto-increment
60+ latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.2.6")
61+ echo "Latest tag: $latest_tag"
62+
4063 # Extract version numbers and increment patch
4164 version=${latest_tag#v}
4265 IFS='.' read -r major minor patch <<< "$version"
4366
4467 # Increment patch version
4568 new_patch=$((patch + 1))
4669 new_version="v$major.$minor.$new_patch"
70+ echo "Auto-incremented version: $new_version"
4771 fi
4872
49- echo "New version: $new_version"
73+ echo "Final version: $new_version"
5074 echo "new_version=$new_version" >> $GITHUB_OUTPUT
5175
5276 - name : Configure Git
0 commit comments