-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
generate_changelog.sh
executable file
·33 lines (27 loc) · 1.13 KB
/
generate_changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
version=$( git describe --tags --always )
tag=$( git describe --tags --always --abbrev=0 )
if [ "$version" = "$tag" ]; then # on a tag
current="$tag"
previous=$( git describe --tags --abbrev=0 HEAD~ )
if [[ $previous == *beta* ]]; then
if [[ $tag == *beta* ]]; then
previous=$( git describe --tags --abbrev=0 HEAD~ )
else
previous=$( git describe --tags --abbrev=0 --exclude="*beta*" HEAD~ )
fi
else
previous=$( git describe --tags --abbrev=0 HEAD~ )
fi
else
current=$( git log -1 --format="%H" )
previous="$tag"
fi
date=$( git log -1 --date=short --format="%ad" )
url=$( git remote get-url upstream | sed -e 's/^git@\(.*\):/https:\/\/\1\//' -e 's/\.git$//' )
echo -ne "# [${version}](${url}/tree/${current}) ($date)\n\n[Full Changelog](${url}/compare/${previous}...${current})\n\n" > "CHANGELOG.md"
if [ "$version" = "$tag" ]; then # on a tag
highlights=$( git cat-file -p "$tag" | sed -e '1,5d' )
echo -ne "## Highlights\n\n ${highlights} \n\n## Commits\n\n" >> "CHANGELOG.md"
fi
git shortlog --no-merges --reverse "$previous..$current" | sed -e '/^\w/G' -e 's/^ /- /' >> "CHANGELOG.md"