Skip to content

Commit a20c195

Browse files
committed
feat(add changelog sh):
1 parent 998c000 commit a20c195

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

changelog.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Get the last tag
4+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
5+
6+
if [ -z "$LAST_TAG" ]; then
7+
echo "No tags found. Retrieving all commits."
8+
LOG_RANGE="HEAD"
9+
else
10+
echo "Generating changelog from last tag: $LAST_TAG"
11+
LOG_RANGE="$LAST_TAG..HEAD"
12+
fi
13+
14+
# Retrieve commit messages excluding merge commits and format them with author names and stripped email domain as nickname
15+
CHANGELOG=$(git log --pretty=format:"- %s by %an, @%ae)" --no-merges $LOG_RANGE | sed -E 's/@([^@]+)@([^@]+)\..*/@\1/')
16+
17+
# Output the changelog
18+
if [ -n "$CHANGELOG" ]; then
19+
echo "# Changelog"
20+
echo "
21+
## Changes since $LAST_TAG"
22+
echo "$CHANGELOG"
23+
else
24+
echo "No new commits since last tag."
25+
fi

0 commit comments

Comments
 (0)