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