forked from jordonwow/bigdebuffs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_changelog.sh
executable file
·30 lines (25 loc) · 1005 Bytes
/
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
#!/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 origin | 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
git cat-file -p "$tag" | sed -e '1,5d' -e '/^-----BEGIN PGP/,/^-----END PGP/d' >> "CHANGELOG.md"
fi