-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update-changelog.sh
executable file
·62 lines (54 loc) · 1.69 KB
/
update-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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -e
sed -n "0,/^\[/ p" CHANGELOG.md | head -n -1 > CHANGELOG.new
{
emit() {
echo "## [$1] - $4" >&4
if [[ -z $3 ]]; then
echo "[$1]: https://github.com/Own-Data-Privateer/hoardy-web/releases/tag/$2"
else
echo "[$1]: https://github.com/Own-Data-Privateer/hoardy-web/compare/$3...$2"
fi
}
prev_extension=
prev_tool=
prev_simple_server=
git tag --sort=-refname --sort=taggerdate --format '%(taggerdate:short) %(subject) %(refname:short)' | while IFS= read -r -d $'\n' line ; do
refname=${line##* }
date=${line%% *}
title=$line
title=${title#* }
title=${title% *}
title=$(sed 's/ version /-v/' <<< "$title")
case "$refname" in
extension-*)
emit "$title" "$refname" "$prev_extension" "$date"
prev_extension="$refname"
;;
tool-v0.15.5)
# skip these
continue
;;
tool-*)
emit "$title" "$refname" "$prev_tool" "$date"
prev_tool="$refname"
;;
dumb_server-*|simple_server-*)
emit "$title" "$refname" "$prev_simple_server" "$date"
prev_simple_server="$refname"
;;
esac
done
} 4> CHANGELOG.spine.rnew | tac >> CHANGELOG.new
{
echo
sed -n "/^# TODO/,$ p" CHANGELOG.md
} >> CHANGELOG.new
{
echo "# Changelog"
cat CHANGELOG.spine.rnew | tac
} >> CHANGELOG.spine.new
sed -n '/^# TODO/,$ d; /^##\? / p' CHANGELOG.md | sed 's/^\(## [^:]*\): .*/\1/g' > CHANGELOG.spine.old
diff -u CHANGELOG.spine.old CHANGELOG.spine.new || true
rm CHANGELOG.spine.*
mv CHANGELOG.new CHANGELOG.md