Skip to content

Commit 8fd9fc7

Browse files
committed
ci: add automatic semantic version bumping for feat/fix commits
1 parent 825fbee commit 8fd9fc7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/bump-version.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -e
3+
4+
version=$(grep 'version=' version.properties | cut -d'=' -f2)
5+
IFS='.' read -r major minor patch <<< "$version"
6+
7+
if git log -1 --pretty=%B | grep -q "^feat:"; then
8+
minor=$((minor + 1))
9+
patch=0
10+
elif git log -1 --pretty=%B | grep -q "^fix:"; then
11+
patch=$((patch + 1))
12+
else
13+
echo "No version bump needed."
14+
exit 0
15+
fi
16+
17+
new_version="$major.$minor.$patch"
18+
echo "Bumping version to $new_version"
19+
20+
echo "version=$new_version" > version.properties
21+
22+
git config user.name "github-actions"
23+
git config user.email "github-actions@github.com"
24+
git commit -am "chore: bump version to $new_version"
25+
git tag "v$new_version"
26+
git push origin HEAD --tags

0 commit comments

Comments
 (0)