Add scripts/release_helper.sh.
[grml-live.git] / scripts / release_helper.sh
1 #!/bin/bash
2 # Filename:      scripts/release_helper.sh
3 # Purpose:       helper script to build grml-live Debian packages (WFM style though)
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -e
10 set -u
11
12 debian_version=''
13 script_version=''
14
15 if git status --porcelain | grep -q '^?? '; then
16   printf "Uncommited changes in current working tree. Please commit/clean up.\n"
17   exit 1
18 fi
19
20 printf "Building debian/changelog: "
21 git-dch --debian-branch="$(git branch | awk -F\*\  '/^* / { print $2}' )" \
22         --since=v$(dpkg-parsechangelog | awk '/^Version:/ {print $2}') \
23         --id-length=7 --meta --multimaint-merge -S
24 printf "OK\n"
25
26 $EDITOR debian/changelog
27
28 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
29
30 dorelease="true"
31 if echo "$debian_version" | grep -q '\.gbp' ; then
32   printf "Building snapshot version, not releasing.\n"
33   dorelease="false"
34 fi
35
36 printf "Updating GRML_LIVE_VERSION string in grml-live script: "
37 sed -i "s/^GRML_LIVE_VERSION=.*/GRML_LIVE_VERSION='$debian_version'/" grml-live
38 printf "OK\n"
39
40 printf "Comparing versions of debian/changelog with grml-live version string: "
41 script_version="$(awk -F= '/^GRML_LIVE_VERSION=/ {print $2}' grml-live | sed "s/'//g")"
42 debian_version="$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')"
43
44 if [[ "$script_version" == "$debian_version" ]] ; then
45   printf "OK\n"
46 else
47   printf "FAILED\n."
48   printf "Debian package version ($debian_version) does not match script version ($script_version).\n"
49   exit 1
50 fi
51
52 if $dorelease ; then
53   git add debian/changelog grml-live
54   git commit -s -m "Release new version ${debian_version}."
55 fi
56
57 printf "Building debian packages:\n"
58 git-buildpackage --git-debian-branch="$(git branch | awk -F\*\  '/^* / { print $2}' )" --git-ignore-new
59 printf "Finished execution of $(basename $0). Do not forget to tag release ${debian_version}\n"
60
61 ## END OF FILE #################################################################