-
Notifications
You must be signed in to change notification settings - Fork 107
/
make-release.sh
executable file
·110 lines (97 loc) · 3.18 KB
/
make-release.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
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
106
107
108
109
110
#!/usr/bin/env bash
die() {
echo $* > /dev/stderr
exit 1
}
# find current release according to configure.ac
CURRELEASE=$(sed -n '/^AC_INIT/s/^.*\[\([0-9.]\+\)\].*$/\1/p' configure.ac)
[[ -z ${CURRELEASE} ]] && die "no release found from configure.ac"
# check this is the last release in the ChangeLog
CLRELEASE=$(sed -n 's/^# \([0-9.]\+\) ([0-9-]\{10\})/\1/p' ChangeLog.md \
| head -n1)
[[ -z ${CLRELEASE} ]] && die "could not get latest release from ChangeLog.md"
[[ ${CURRELEASE} != ${CLRELEASE} ]] && \
die "configure.ac ($CURRELEASE) and ChangeLog.md (${CLRELEASE}) disagree"
# prepare new version and release date
TODAY=$(date +%F)
EUTODAY=$(date +%d-%m-%Y)
if [[ $1 == "-M" || $1 == "--major" ]] ; then
# major version bump
NEXTRELEASE="$(( ${CURRELEASE%%.*} + 1 )).0"
FUTURERELEASE="${NEXTRELEASE%.0}.1"
elif [[ $1 == "-B" || $1 == "--bugfix" ]] ; then
# bugfix release
MINOR=${CURRELEASE#*.}
SUF=0
if [[ ${MINOR} == *.* ]] ; then
SUF=${MINOR#*.}
MINOR=${MINOR%.*}
fi
NEXTRELEASE="${CURRELEASE%%.*}.${MINOR}.$(( ${SUF} + 1 ))"
FUTURERELEASE="${CURRELEASE%%.*}.$(( ${MINOR} + 1 ))"
else
# minor version bump
MINOR=${CURRELEASE#*.}
NEXTRELEASE="${CURRELEASE%%.*}.$(( ${MINOR%%.*} + 1 ))"
FUTURERELEASE="${CURRELEASE%%.*}.$(( ${MINOR%%.*} + 2 ))"
fi
echo "Performing version bump from ${CURRELEASE} to ${NEXTRELEASE} (${TODAY})"
# prepare modifications to configure.ac and ChangeLog.md
CHANGES=.make-release-tmp.$$
mkdir "${CHANGES}"
trap "rm -Rf ${CHANGES}" EXIT
sed -e "/^AC_INIT/s:\[${CURRELEASE}\]:[${NEXTRELEASE}]:" \
-e "/^AC_SUBST(\[RELEASEDATE\]/d" \
-e "/^AC_INIT/a AC_SUBST([RELEASEDATE], [${TODAY}])" \
-e "/^AM_MAINTAINER_MODE/s:\[enable\]:[disable\]:" \
configure.ac \
| diff -u \
--label "${CURRELEASE}/configure.ac" \
--label "${NEXTRELEASE}/configure.ac" \
configure.ac - \
>> "${CHANGES}"/srcdiffs
{
echo "# ${FUTURERELEASE} (unreleased master branch)"
echo
echo "### New Features"
echo
echo "### Bugfixes"
echo
echo
echo "# ${NEXTRELEASE} (${EUTODAY})"
sed -e "1d" ChangeLog.md
} | diff -u \
--label "${CURRELEASE}/ChangeLog.md" \
--label "${NEXTRELEASE}/ChangeLog.md" \
ChangeLog.md - \
>> "${CHANGES}"/srcdiffs
cat "${CHANGES}"/srcdiffs
read -p "do you want to apply these changes? [yN] " answ
[[ ${answ} == "y" ]] || die "aborting"
patch -p1 < "${CHANGES}"/srcdiffs
echo "regenerating build files"
autoreconf -fiv || die
echo "committing and tagging version bump"
git commit --signoff -am "version bump to ${NEXTRELEASE}" || die
git tag "v${NEXTRELEASE}" || die
echo "restoring maintainer-mode in configure.ac"
sed -i \
-e "/^AM_MAINTAINER_MODE/s:\[disable\]:[enable\]:" \
configure.ac || die
autoreconf -fiv || die
git commit --signoff -am "configure.ac: restoring maintainer mode"
echo "building release tar"
SRCDIR=${PWD}
mkdir "${CHANGES}"/build || die
pushd "${CHANGES}"/build || die
git clone "${SRCDIR}" carbon-c-relay
pushd carbon-c-relay
git checkout "v${NEXTRELEASE}" || die
libtoolize || glibtoolize # get m4 macros for dist
./configure
make dist
mv carbon-c-relay-${NEXTRELEASE}.tar.* "${SRCDIR}"/ || die
popd || die
popd || die
RELEASETAR=$(echo carbon-c-relay-${NEXTRELEASE}.tar.*)
echo "please git push && git push --tags if ${RELEASETAR} is ok"