id-pbuild.sh: clear distro list if distro option is given
[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 echo "Did you updated the news log file?"
25 for file in Changes News NEWS
26 do
27   if [ -e $file ]; then
28     ls -l $file
29   fi
30 done
31 echo ""
32
33 if [ -e "pom.xml" ]; then
34     java=true
35 else
36     java=false
37 fi
38
39 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
40     perl=true
41 else
42     perl=false
43 fi
44
45 if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
46     usage "No *.spec file found"
47 else
48     spec=`ls |egrep '\.spec$' | head -1`
49     package=`perl -ne 's/\s*$//; print if s/^NAME=//' IDMETA`
50     if [ -z "$package" ]; then
51         package=`basename $spec .spec`
52     fi
53 fi
54
55 # configure new version
56 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
57
58 if $java; then
59     echo "set maven version to $version"
60     mvn versions:set -DnewVersion=$version > mvn-versions.log
61 fi
62
63 if $perl; then
64   echo "check perl version numbers"
65   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]' | egrep -v '^\./deb-src/'
66 fi
67
68 # update debian version file
69 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
70
71 # update redhat version file
72 perl -i.bak -npe "s,^Version: \d+.*,Version: $version," $spec
73
74
75
76 ######################################################################
77 echo ""
78 echo "# Please commit the version updates now"
79 echo "git commit -a -m'new release v$version'"
80 echo ""
81 echo "# Please run now"
82 echo "git push"
83 echo "git tag v$version"
84 echo "git push origin tag v$version"
85
86 if $java; then
87     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
88 fi
89
90 ######################################################################
91 echo ""
92 echo "# On RedHat or centos, please run the commands"
93 echo "sudo date # ask for password early"
94 echo "git pull"
95 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
96 echo "sudo cp $package-$version.tar.gz /usr/src/redhat/SOURCES/"
97 echo "sudo rpmbuild -ba $spec"
98 echo "# if successfully, scp the package to ftp.indexdata.dk (kebab)"
99 echo "\$HOME/proj/git-tools/id-rpm-build/upload-rpms.sh $spec"
100 echo ""
101 echo "# on kebab run: sudo su"
102 echo "#               cd $HOME/proj/git-tools/update-archive && ./update-yum-archive.sh"
103
104
105 ######################################################################
106 echo ""
107 echo "# On debian or ubuntu, please run the commands"
108 echo "sudo rm -rf deb-src"
109 echo "git pull"
110 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
111 echo "\$HOME/proj/git-tools/id-deb-build/id-mk-deb-src.sh"
112 echo "sudo \$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
113 echo "# if successfully, scp the package to ftp.indexdata.dk (kebab)"
114 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
115 echo ""
116 echo "# on kebab run: sudo su"
117 echo "#               cd $HOME/proj/git-tools/update-archive && ./update-archive.sh"
118 echo ""
119
120