@@ -3,9 +3,13 @@ name: Release
33on :
44 workflow_dispatch :
55 inputs :
6- version :
6+ version_bump :
77 required : true
8- description : ' Release version'
8+ description : ' Version bump type'
9+ type : choice
10+ options :
11+ - major
12+ - minor
913
1014jobs :
1115 release_pr :
3943 git checkout -b releases origin/releases
4044 fi
4145
46+ - name : Calculate next version
47+ id : version
48+ run : |
49+ # Get the latest tag (no longer using v prefix, filter out legacy v-prefixed tags)
50+ LATEST_TAG=$(git tag | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
51+
52+ # Stop build if no version tag is found
53+ if [ -z "$LATEST_TAG" ]; then
54+ echo "Error: No semantic version tags found in repository"
55+ echo "Expected format: X.Y.Z (e.g., 12.5.0)"
56+ exit 1
57+ fi
58+
59+ echo "Latest tag found: $LATEST_TAG"
60+
61+ # Extract version numbers (remove 'v' prefix if present for backwards compatibility)
62+ VERSION_WITHOUT_V=${LATEST_TAG#v}
63+
64+ # Parse major and minor (ignore patch since we don't support it)
65+ MAJOR=$(echo $VERSION_WITHOUT_V | cut -d. -f1)
66+ MINOR=$(echo $VERSION_WITHOUT_V | cut -d. -f2)
67+
68+ # Calculate next version based on input
69+ if [ "${{ github.event.inputs.version_bump }}" = "major" ]; then
70+ NEXT_MAJOR=$((MAJOR + 1))
71+ NEXT_MINOR=0
72+ else
73+ NEXT_MAJOR=$MAJOR
74+ NEXT_MINOR=$((MINOR + 1))
75+ fi
76+
77+ # Create new version (always without v prefix)
78+ NEXT_VERSION="${NEXT_MAJOR}.${NEXT_MINOR}.0"
79+
80+ echo "Next version: $NEXT_VERSION"
81+ echo "RELEASE_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
82+ echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
83+
4284 - name : Collect commit ranges
4385 run : |
4486 bash ./scripts/changelog.sh > ${{ github.workspace }}/CHANGELOG.txt
69111 - name : Commit build files
70112 uses : stefanzweifel/git-auto-commit-action@v7
71113 with :
72- commit_message : ' Release build ${{ github.event.inputs .version }} [ci release]'
114+ commit_message : ' Release build ${{ steps.version.outputs .version }} [ci release]'
73115 commit_options : ' --allow-empty'
74116 skip_checkout : true
75117 branch : ' releases'
87129 body_path : ${{ github.workspace }}/CHANGELOG.txt
88130 draft : false
89131 prerelease : false
90- tag_name : ${{ github.event.inputs .version }}
132+ tag_name : ${{ steps.version.outputs .version }}
91133 target_commitish : ' releases'
0 commit comments