git-tools: concurrency for pbuilder builds SA-768
[git-tools-moved-to-github.git] / id-release
1 #!/bin/sh
2 # Copyright (c) 2011-2015 IndexData ApS. http://indexdata.com
3 # Author: Wolfram Schneider
4 #
5 # id-release - a helper script to build a release & packaging for debian + redhat
6 #
7 # see http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/IDSoftwareRelease
8 # https://twiki.indexdata.com/twiki/bin/view/ID/AdamsReleaseProcedure
9
10 # die early
11 set -e
12
13 usage () {
14     echo  >&2 "usage $0 version"
15     echo  >&2 "$@"
16     exit 1
17 }
18
19 ######################################################################
20 case $1 in
21   [0-9]* ) version=$1 ;;
22        * ) usage ;;
23 esac
24
25 cat <<EOF
26 #!/bin/sh
27 #
28 # See also https://twiki.indexdata.com/twiki/bin/view/ID/AdamsReleaseProcedure
29 #
30
31 set -e
32
33 EOF
34
35 echo "# Did you updated the news log file?"
36 for file in Changes News NEWS
37 do
38   if [ -e $file ]; then
39     echo "# $(ls -l $file)"
40   fi
41 done
42 echo ""
43
44 if [ -e "pom.xml" ]; then
45     java=true
46 else
47     java=false
48 fi
49
50 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
51     perl=true
52 else
53     perl=false
54 fi
55
56 if [ `ls | egrep '\.spec$' | wc -l` -eq 0 ]; then
57     usage "No *.spec file found"
58 else
59     spec=`ls |egrep '\.spec$' | head -1`
60     package=`perl -ne 's/\s*$//; print if s/^NAME=//' IDMETA`
61     if [ -z "$package" ]; then
62         package=`basename $spec .spec`
63     fi
64 fi
65
66 # configure new version
67 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
68
69 if $java; then
70     echo "# set maven version to $version"
71     mvn versions:set -DnewVersion=$version > mvn-versions.log
72 fi
73
74 if $perl; then
75   echo "# check perl version numbers"
76   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]' | 
77         egrep -v '^\./deb-src/' | perl -npe 's,^,# ,'
78 fi
79
80 # update debian version file
81 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
82
83 # update redhat version file
84 perl -i.bak -npe "s,^Version: \d+.*,Version: $version," $spec
85
86
87 ######################################################################
88 echo "# Please commit the version updates now"
89 echo "git commit -a -m'new release v$version'"
90 echo ""
91 echo "# Please tag now (we will push later to origin)"
92 echo "git tag v$version"
93
94 if $java; then
95     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
96 fi
97
98 ######################################################################
99 echo ""
100 echo "# On mochi, please run the commands"
101 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
102 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
103 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
104 echo ""
105
106 echo "# if successfully, don't forget to push to origin"
107 echo "git push origin master"
108 echo "git push origin tag v$version"
109
110 # EOF
111