blob: 26ebd337b83069bbb0af63f7de5eba3e834c1d98 [file] [log] [blame]
Harald Welteee497f22017-10-03 16:54:41 +08001#!/bin/sh
2VERSION=$1
3REL=$2
4
5if [ "z$REL" = "z" ]; then
6 echo "No REL value specified, defaulting to 'patch' release"
Pau Espin Pedrol941fd9b2018-08-30 12:42:37 +02007 REL="patch"
Harald Welteee497f22017-10-03 16:54:41 +08008fi
9
Pau Espin Pedrolcf8497c2018-08-30 12:56:53 +020010ALLOW_NO_LIBVERSION_CHANGE="${ALLOW_NO_LIBVERSION_CHANGE:-0}"
11
Harald Welteee497f22017-10-03 16:54:41 +080012BUMPVER=`command -v bumpversion`
13
14NEW_VER=`bumpversion --list --current-version $VERSION $REL --allow-dirty | awk -F '=' '{ print $2 }'`
15LIBVERS=`git grep -n LIBVERSION | grep '=' | grep am | grep -v LDFLAGS`
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020016MAKEMOD=`git diff --cached -GLIBVERSION --stat | grep Makefile.am`
Harald Welteee497f22017-10-03 16:54:41 +080017ISODATE=`date -I`
18
19if [ "z$BUMPVER" = "z" ]; then
20 echo Unable to find 'bumpversion' command.
21 exit 1
22fi
23
24if [ "z$NEW_VER" = "z" ]; then
25 echo "Please fix versioning to match http://semver.org/ spec (current is $VERSION) before proceeding."
26 exit 1
27fi
28
29echo "Releasing $VERSION -> $NEW_VER..."
30
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020031if [ "z$LIBVERS" != "z" ]; then
Pau Espin Pedrolcf8497c2018-08-30 12:56:53 +020032 if [ "z$MAKEMOD" = "z" ] && [ "z$ALLOW_NO_LIBVERSION_CHANGE" = "z0" ]; then
33 echo "ERROR: Before releasing, please modify some of the libversions: $LIBVERS"
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020034 echo "You should NOT be doing this unless you've read and understood following article:"
35 echo "https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info"
Pau Espin Pedrol0b0f9082018-05-02 15:58:37 +020036 exit 1
Harald Welteee497f22017-10-03 16:54:41 +080037 fi
Pau Espin Pedrolcf8497c2018-08-30 12:56:53 +020038
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020039 if [ -f "TODO-RELEASE" ]; then
40 grep '#' TODO-RELEASE > TODO-RELEASE.clean
41 mv TODO-RELEASE.clean TODO-RELEASE
42 git add TODO-RELEASE
43 fi
Harald Welteee497f22017-10-03 16:54:41 +080044fi
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020045gbp dch --debian-tag='%(version)s' --auto --meta --git-author --multimaint-merge --ignore-branch --new-version="$NEW_VER"
Harald Welteee497f22017-10-03 16:54:41 +080046dch -r -m --distribution "unstable" ""
Pau Espin Pedrol01dd5702018-05-03 15:01:47 +020047git add debian/changelog
Harald Welteee497f22017-10-03 16:54:41 +080048bumpversion --current-version $VERSION $REL --tag --commit --tag-name $NEW_VER --allow-dirty
Pau Espin Pedrolbf819322018-05-03 15:25:11 +020049git commit --amend # let the user add extra information to the release commit.
Harald Welteee497f22017-10-03 16:54:41 +080050git tag -s $NEW_VER -f -m "Release v$NEW_VER on $ISODATE."
51echo "Release $NEW_VER prepared, tagged and signed."