Created
April 28, 2025 08:38
-
-
Save legout/3e81dc163a4fe0a07996aeba15a7efec to your computer and use it in GitHub Desktop.
Auto update Changelog on version bump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./update_changelog.sh <previous_tag> <new_version> | |
set -e | |
PREV_TAG="$1" | |
NEW_VERSION="$2" | |
if [ -z "$PREV_TAG" ] || [ -z "$NEW_VERSION" ]; then | |
echo "Usage: $0 <previous_tag> <new_version>" | |
exit 1 | |
fi | |
DATE=$(date +%Y-%m-%d) | |
echo "Generating changelog from $PREV_TAG to HEAD..." | |
CHANGELOG="## [$NEW_VERSION] - $DATE | |
" | |
CHANGELOG+=$(git log "$PREV_TAG"..HEAD --merges --pretty=format:"- %s" | sed 's/^/ /') | |
# Print to screen | |
echo "" | |
echo "------ COPY BELOW ------" | |
echo "" | |
echo "$CHANGELOG" | |
echo "" | |
echo "------ COMMIT COMMAND ------" | |
echo "" | |
echo "git commit -am \"Bump version to $NEW_VERSION | |
Changes: | |
$(git log "$PREV_TAG"..HEAD --merges --pretty=format:"- %s") | |
\"" | |
echo "" | |
echo "------ TAG COMMAND ------" | |
echo "" | |
echo "git tag v$NEW_VERSION" | |
echo "" | |
echo "------ END ------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment