chore: add semantic versioning and automatic changelog generation

- Add cliff.toml config for git-cliff with conventional commit parsing
- Create scripts/release.sh for automated version bumping
- Generate CHANGELOG.md from git history with semver tags (v1.0.0, v1.7.2)
- Release workflow: ./scripts/release.sh {major|minor|patch|VERSION}
This commit is contained in:
mguschin
2026-03-05 21:12:39 +03:00
parent bd0ff8f449
commit d486ba1f83
3 changed files with 108 additions and 9 deletions

51
scripts/release.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#
# Release script: bump version, generate changelog, commit, and tag.
#
# Usage:
# ./scripts/release.sh <major|minor|patch>
# ./scripts/release.sh 2.0.0 # explicit version
#
set -euo pipefail
VERSION_FILE="version"
current_version=$(cat "$VERSION_FILE")
echo "Current version: $current_version"
IFS='.' read -r major minor patch <<< "$current_version"
case "${1:-}" in
major) new_version="$((major + 1)).0.0" ;;
minor) new_version="${major}.$((minor + 1)).0" ;;
patch) new_version="${major}.${minor}.$((patch + 1))" ;;
"")
echo "Usage: $0 <major|minor|patch|VERSION>"
exit 1
;;
*)
# Validate explicit semver
if [[ ! "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: '$1' is not a valid semver (X.Y.Z)"
exit 1
fi
new_version="$1"
;;
esac
echo "Bumping to: $new_version"
# Update version file
echo "$new_version" > "$VERSION_FILE"
# Generate changelog
git-cliff --tag "v${new_version}" --output CHANGELOG.md
# Commit and tag
git add "$VERSION_FILE" CHANGELOG.md
git commit -m "chore(release): v${new_version}"
git tag "v${new_version}"
echo ""
echo "Released v${new_version}"
echo "Don't forget to push: git push && git push --tags"