Merge branch 'master' of ssh://hummus/home/git/pub/git-tools
[git-tools-moved-to-github.git] / id-release
index 8462c78..22035f8 100755 (executable)
@@ -1,18 +1,57 @@
 #!/bin/sh
-# Copyright (c) 2011 IndexData ApS. http://indexdata.com
+# Copyright (c) 2011-2015 IndexData ApS. http://indexdata.com
 # Author: Wolfram Schneider
 #
 # id-release - a helper script to build a release & packaging for debian + redhat
+#
+# see http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/IDSoftwareRelease
+# https://twiki.indexdata.com/twiki/bin/view/ID/AdamsReleaseProcedure
 
 # die early
 set -e
 
 usage () {
-    echo "usage $0 version"
+    echo  >&2 "usage $0 version"
+    echo  >&2 "$@"
     exit 1
 }
 
+branch_check () {
+    if ! git branch | egrep -q '^\* master$'; then
+       ( echo ">>> Warning: you are not running on the master branch <<<"
+         git branch; echo ) 1>&2
+    fi
+}
+
 ######################################################################
+branch_check
+
+case $1 in
+  [0-9]* ) version=$1 ;;
+       * ) usage ;;
+esac
+
+
+
+cat <<EOF
+#!/bin/sh
+#
+# See also https://twiki.indexdata.com/twiki/bin/view/ID/AdamsReleaseProcedure
+#
+
+set -e
+
+EOF
+
+echo "# Did you updated the news log file?"
+for file in Changes News NEWS
+do
+  if [ -e $file ]; then
+    echo "# $(ls -l $file)"
+  fi
+done
+echo ""
+
 if [ -e "pom.xml" ]; then
     java=true
 else
@@ -25,42 +64,43 @@ else
     perl=false
 fi
 
-if [ `ls |egrep '\.spec$' | wc -l` -eq 0 ]; then
-    echo "No *.spec file found"
-    usage
+if [ `ls | egrep '\.spec$' | wc -l` -eq 0 ]; then
+    usage "No *.spec file found"
 else
     spec=`ls |egrep '\.spec$' | head -1`
-    package=`basename $spec .spec`
+    package=`perl -ne 's/\s*$//; print if s/^NAME=//' IDMETA`
+    if [ -z "$package" ]; then
+       package=`basename $spec .spec`
+    fi
 fi
 
-case $1 in
-  [0-9]* ) version=$1 ;;
-       * ) usage ;;
-esac
-
 # configure new version
 perl -i.bak -npe "s,VERSION=.*,VERSION=$version," IDMETA
 
 if $java; then
-    echo "set maven version to $version"
+    echo "# set maven version to $version"
     mvn versions:set -DnewVersion=$version > mvn-versions.log
 fi
 
 if $perl; then
-  echo "check perl version numbers"
-  find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]'
+  echo "# check perl version numbers"
+  find . -name '*.pm' -print0 | xargs -0 egrep -H '\$VERSION.*=.*[0-9]' | 
+       egrep -v '^\./deb-src/' | perl -npe 's,^,# ,'
 fi
 
 # update debian version file
 perl -i.bak -npe "\$. == 1 && s,\(.*?\),($version)," debian/changelog 
 
+# update redhat version file
+perl -i.bak -npe "s,^Version: \d+.*,Version: $version," $spec
+
+
 ######################################################################
+echo "# Please commit the version updates now"
+echo "git commit -a -m'new release v$version'"
 echo ""
-echo "# Please run now"
-echo "git commit -a"
-echo "git push"
+echo "# Please tag now (we will push later to origin)"
 echo "git tag v$version"
-echo "git push origin tag v$version"
 
 if $java; then
     echo "mvn versions:set -DnewVersion=$version-SNAPSHOT" 
@@ -68,11 +108,15 @@ fi
 
 ######################################################################
 echo ""
-echo "# On RedHat or centos, please run the commands"
-echo "$HOME/proj/git-tools/id-deb-build/mkdist.sh"
-echo "sudo cp $package-$version.tar.gz /usr/src/redhat/SOURCES/"
-echo "sudo rpmbuild -ba $spec"
-echo "$HOME/proj/git-tools/id-rpm-build/upload-rpms.sh $spec"
-echo "# on kebab run update-yum-archive.sh"
+echo "# On mochi, please run the commands"
+echo "\$HOME/proj/git-tools/id-deb-build/mkdist.sh"
+echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
+echo "\$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
+echo ""
+
+echo "# if successfully, don't forget to push to origin"
+echo "git push origin master"
+echo "git push origin tag v$version"
 
+# EOF