1+ name : Semantic Version Bump (Conventional Commits)
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ semver-bump :
10+ runs-on : ubuntu-latest
11+ if : github.event.head_commit.author.name != 'github-actions[bot]'
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ - name : Determine bump type from commit message
18+ id : bump
19+ run : |
20+ COMMIT_MSG="${{ github.event.head_commit.message }}"
21+ echo "🔍 Commit message: $COMMIT_MSG"
22+
23+ if echo "$COMMIT_MSG" | grep -qE 'BREAKING CHANGE|!:'; then
24+ echo "bump=major" >> $GITHUB_OUTPUT
25+ elif echo "$COMMIT_MSG" | grep -qE '^feat(\(.+\))?:'; then
26+ echo "bump=minor" >> $GITHUB_OUTPUT
27+ elif echo "$COMMIT_MSG" | grep -qE '^fix(\(.+\))?:'; then
28+ echo "bump=patch" >> $GITHUB_OUTPUT
29+ else
30+ echo "bump=none" >> $GITHUB_OUTPUT
31+ fi
32+
33+ - name : Bump version in fxmanifest.lua
34+ if : steps.bump.outputs.bump != 'none'
35+ run : |
36+ FILE="fxmanifest.lua"
37+ VERSION_LINE=$(grep -E "version ['\"]?[0-9]+\.[0-9]+\.[0-9]+['\"]?" "$FILE")
38+ VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")
39+
40+ IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
41+
42+ case "${{ steps.bump.outputs.bump }}" in
43+ major)
44+ MAJOR=$((MAJOR + 1))
45+ MINOR=0
46+ PATCH=0
47+ ;;
48+ minor)
49+ MINOR=$((MINOR + 1))
50+ PATCH=0
51+ ;;
52+ patch)
53+ PATCH=$((PATCH + 1))
54+ ;;
55+ esac
56+
57+ NEW_VERSION="$MAJOR.$MINOR.$PATCH"
58+ sed -i "s/version ['\"]$VERSION['\"]/version '$NEW_VERSION'/" "$FILE"
59+ echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
60+
61+ - name : Commit and push version bump
62+ if : steps.bump.outputs.bump != 'none'
63+ run : |
64+ git config user.name "github-actions[bot]"
65+ git config user.email "github-actions[bot]@users.noreply.github.com"
66+ git add fxmanifest.lua
67+
68+ if git diff --cached --quiet; then
69+ echo "⚠️ No version changes to commit."
70+ exit 0
71+ fi
72+
73+ COMMIT_MSG="${{ github.event.head_commit.message }}"
74+ git commit -m "ci: bump fxmanifest version to ${{ env.new_version }} – $COMMIT_MSG"
75+ git push
0 commit comments