redhat rules
[git-tools-moved-to-github.git] / id-release
1 #!/bin/sh
2 # Copyright (c) 2011 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 # die early
8 set -e
9
10 usage () {
11     echo "usage $0 version"
12     exit 1
13 }
14
15 ######################################################################
16 if [ -e "pom.xml" ]; then
17     java=true
18 else
19     java=false
20 fi
21
22 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
23     perl=true
24 else
25     perl=false
26 fi
27
28 if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
29     echo "No *.spec file found"
30     usage
31 else
32     spec=`ls |egrep '\.spec$' | head -1`
33     package=`basename $spec .spec`
34 fi
35
36 case $1 in
37   [0-9]* ) version=$1 ;;
38        * ) usage ;;
39 esac
40
41 # configure new version
42 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
43
44 if $java; then
45     echo "set maven version to $version"
46     mvn versions:set -DnewVersion=$version > mvn-versions.log
47 fi
48
49 if $perl; then
50   echo "check perl version numbers"
51   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]'
52 fi
53
54 # update debian version file
55 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
56
57 ######################################################################
58 echo ""
59 echo "# Please run now"
60 echo "git commit -a"
61 echo "git push"
62 echo "git tag v$version"
63 echo "git push origin tag v$version"
64
65 if $java; then
66     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
67 fi
68
69 ######################################################################
70 echo ""
71 echo "# On RedHat or centos, please run the commands"
72 echo "$HOME/proj/git-tools/id-deb-build/mkdist.sh"
73 echo "sudo cp $package-$version.tar.gz /usr/src/redhat/SOURCES/"
74 echo "sudo rpmbuild -ba $spec"
75 echo "$HOME/proj/git-tools/id-rpm-build/upload-rpms.sh $spec"
76 echo "# on kebab run update-yum-archive.sh"
77
78