rewritten to use the new lcx setup
[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 echo "See also https://twiki.indexdata.com/twiki/bin/view/ID/AdamsReleaseProcedure"
26 echo ""
27
28 echo "Did you updated the news log file?"
29 for file in Changes News NEWS
30 do
31   if [ -e $file ]; then
32     ls -l $file
33   fi
34 done
35 echo ""
36
37 if [ -e "pom.xml" ]; then
38     java=true
39 else
40     java=false
41 fi
42
43 if [ `find . -name '*.pm' | wc -l` -gt 0 ]; then
44     perl=true
45 else
46     perl=false
47 fi
48
49 if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
50     usage "No *.spec file found"
51 else
52     spec=`ls |egrep '\.spec$' | head -1`
53     package=`perl -ne 's/\s*$//; print if s/^NAME=//' IDMETA`
54     if [ -z "$package" ]; then
55         package=`basename $spec .spec`
56     fi
57 fi
58
59 # configure new version
60 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
61
62 if $java; then
63     echo "set maven version to $version"
64     mvn versions:set -DnewVersion=$version > mvn-versions.log
65 fi
66
67 if $perl; then
68   echo "check perl version numbers"
69   find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]' | egrep -v '^\./deb-src/'
70 fi
71
72 # update debian version file
73 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
74
75 # update redhat version file
76 perl -i.bak -npe "s,^Version: \d+.*,Version: $version," $spec
77
78
79 ######################################################################
80 echo "# Please commit the version updates now"
81 echo "git commit -a -m'new release v$version'"
82 echo ""
83 echo "# Please tag now (we will push later to origin)"
84 echo "git 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 mochi, please run the commands"
93 echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
94 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
95 echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
96 echo ""
97
98 echo "# if successfully, don't forget to push to origin"
99 echo "git push origin master"
100 echo "git push origin tag v$version"
101