a helper script to build a release & packaging for debian + redhat
[git-tools-moved-to-github.git] / id-release
1 #!/bin/sh
2
3 usage () {
4     echo "usage $0 version"
5     exit 1
6 }
7
8 if [ -e "pom.xml" ]; then
9     java=true
10 else
11     java=false
12 fi
13
14 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
15     perl=true
16 else
17     perl=false
18 fi
19
20 if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
21     echo "No *.spec file found"
22     usage
23 else
24     package=`ls |egrep '\.spec$' | head -1`
25 fi
26
27 case $1 in
28   [0-9]* ) version=$1 ;;
29        * ) usage ;;
30 esac
31
32 # configure new version
33 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
34
35 if $java; then
36     echo "set maven version to $version"
37     mvn versions:set -DnewVersion=$version > mvn-versions.log
38 fi
39
40 if $perl; then
41   echo "check perl version numbers"
42   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]'
43 fi
44
45 # update debian version file
46 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
47
48 ######################################################################
49 echo ""
50 echo "# Please run now"
51 echo "git commit -a"
52 echo "git push"
53 echo "git tag v$version"
54 echo "git push origin tag v$version"
55
56 if $java; then
57     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
58 fi
59