Repository navigation
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·105 lines (91 loc) · 2.62 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·105 lines (91 loc) · 2.62 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
# Usage: sys/release-notes.sh 4.5.1 # from HEAD to 4.5.1
# $ sys/release-notes.sh 4.5.1 -v # same as above but include untagged commits
# $ sys/release-notes.sh 4.5.0 4.5.1 # from 4.5.0 to 4.5.1
#
release_log() {
if [ -n "$PREV" ]; then
git log ${PREV}..${VERS} > .l
else
git log ${VERS} > .l
fi
}
release_notes() {
if [ -n "`git log -n 1 | grep Release`" ]; then
VERS=`git tag --sort=committerdate | grep -v conti | tail -n 1`
PREV=`git tag --sort=committerdate | grep -v conti | tail -n 2 | head -n1`
else
VERS=HEAD
PREV=`git tag --sort=committerdate | grep -v conti | tail -n 1`
fi
[ -n "$1" ] && PREV="$1"
[ -n "$2" ] && VERS="$2"
FIRST_RELEASE=0
if [ "$PREV" = "$VERS" ]; then
if [ "`git tag | wc -l | awk '{print $1}'`" = 1 ]; then
PREV=
FIRST_RELEASE=1
else
PREV=`git tag --sort=committerdate | grep -v conti | tail -n 2 | head -n1`
fi
fi
[ -z "$PREV" ] && [ "$FIRST_RELEASE" = 0 ] && PREV="$(git rev-list --max-parents=0 HEAD)"
release_log
# When HEAD contains a tag do this magic
if [ ! -s .l ]; then
VERS=$PREV
PREV=`git tag --sort=committerdate | grep -v conti | tail -n 2 | head -n1`
release_log
fi
grep ^Author .l | cut -d : -f 2- | sed -e 's,radare,pancake,' | sort -u > .A
CODENAME="`git log | grep -i 'Release' | head -n 1 | cut -d - -f 2- | cut -d ' ' -f 3-`"
echo "## Release Notes"
echo
echo "Codename: ${CODENAME}"
echo "Version: ${VERS}"
echo "Previous: ${PREV}"
printf "Commits: "
grep ^commit .l | wc -l | xargs echo
echo "Contributors: `wc -l .A | awk '{print $1}'`"
echo
echo "## Highlights"
echo "<details><summary>More details</summary><p>"
echo
echo "## Contributors"
echo
cat .A | perl -ne '/([^<]+)(.*)$/;$a=$1;$b=$2;$a=~s/^\s+|\s+$//g;$b=~s/[<>\s]//g;print "[$a](mailto:$b) "'
echo
echo
echo "## Changes"
echo
cat .l | grep -v ^commit | grep -v ^Author | grep -v ^Date > .x
cat .x | grep '##' | perl -ne '/##([^ ]*)/; if ($1) {print "$1\n";}' | sort -u > .y
for a in `cat .y` ; do
echo "**$a**"
echo
cat .x | grep "##$a" | sed -e 's/##.*//g' | perl -ne '{ s/^\s+//; print "* $_"; }'
echo
done
echo "## Raw"
cat .x | grep -v '##' | sed -e 's,^ *,,g' | grep -v "^$" | \
perl -ne 'if (/^\*/) { print "$_"; } else { print "* $_";}'
echo
rm -f .x .y .l .A
echo '</p></details>'
}
release_version() {
if [ -z "$1" ]; then
cat meson.build | grep version | cut -d "'" -f2 | head -n1
else
meson rewrite kwargs set project / version "$1"
fi
}
help_message() {
echo "Usage ./release.sh [-v|-n] (version | notes)"
echo "Change app version with './release.sh -v 1.2.3'"
}
case "$1" in
-n|notes) release_notes ; ;;
-v|version) release_version "$2" ; ;;
*) help_message ; ;;
esac