improve usage()
[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 # see http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/IDSoftwareRelease
8
9 # die early
10 set -e
11
12 usage () {
13     echo  >&2 "usage $0 version"
14     echo  >&2 "$@"
15     exit 1
16 }
17
18 ######################################################################
19 case $1 in
20   [0-9]* ) version=$1 ;;
21        * ) usage ;;
22 esac
23
24 if [ -e "pom.xml" ]; then
25     java=true
26 else
27     java=false
28 fi
29
30 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
31     perl=true
32 else
33     perl=false
34 fi
35
36 if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
37     usage "No *.spec file found"
38 else
39     spec=`ls |egrep '\.spec$' | head -1`
40     package=`perl -ne 's/\s*$//; print if s/^NAME=//' IDMETA`
41 fi
42
43 # configure new version
44 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
45
46 if $java; then
47     echo "set maven version to $version"
48     mvn versions:set -DnewVersion=$version > mvn-versions.log
49 fi
50
51 if $perl; then
52   echo "check perl version numbers"
53   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]'
54 fi
55
56 # update debian version file
57 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
58
59 # update redhat version file
60 perl -i.bak -npe "s,^Version: .*,Version: $version," $spec
61
62 ######################################################################
63 echo ""
64 echo "# Please run now"
65 echo "git commit -a"
66 echo "git push"
67 echo "git tag v$version"
68 echo "git push origin tag v$version"
69
70 if $java; then
71     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
72 fi
73
74 ######################################################################
75 echo ""
76 echo "# On RedHat or centos, please run the commands"
77 echo "sudo date"
78 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
79 echo "sudo cp $package-$version.tar.gz /usr/src/redhat/SOURCES/"
80 echo "sudo rpmbuild -ba $spec"
81 echo "# if successfully, upload"
82 echo "\$HOME/proj/git-tools/id-rpm-build/upload-rpms.sh $spec"
83 echo ""
84 echo "# on kebab run: sudo su; cd \$HOME/proj/git-tools/update-archive; update-yum-archive.sh"
85
86
87 ######################################################################
88 echo ""
89 echo "# On debian or ubuntu, please run the commands"
90 echo "sudo rm -rf deb-src"
91 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
92 echo "\$HOME/proj/git-tools/id-deb-build/id-mk-deb-src.sh"
93 echo "sudo \$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
94 echo "# if successfully, upload"
95 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
96 echo ""
97 echo "# on kebab run: sudo su; cd \$HOME/proj/git-tools/update-archive; update-archive.sh"
98 echo ""
99
100