From 13b90eac7b42684e2748a2657ce080506dff8a73 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Fri, 9 Oct 2015 14:03:02 +0200 Subject: [PATCH] Improved ./release.sh Some more automatization of relase: 1. Version number is guessed based on current branch 2. Date in changelog is automatically set --- release.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/release.sh b/release.sh index f0ff58d7f..13b8c82ef 100755 --- a/release.sh +++ b/release.sh @@ -17,6 +17,19 @@ confirm () { esac } +update_changelog() { + echo $1 $2 $3 + awk -v version="$2" -v date="$3" '{ + if($1=="Version" && $2==version){ + print "Version " version " (" date ")" + done=1 + } else if(!done && $1=="Unreleased" && $2=="changes"){ + print "Version " version " (" date ")" + } else print + }' $1 > $1.tmp + mv $1.tmp $1 +} + VALIDATED= if [ "$1" = --validated ] ; then VALIDATED=yes @@ -27,15 +40,38 @@ elif test -n "$1" ; then fi -echo "*** Only use this script if you want to release a new PLUMED version ***" -echo "*** follow instructions below ***" +echo "*** Only use this script if you want to release a new PLUMED version. ***" +echo "*** Follow instructions below, and use Control-C to exit. ***" ls src README 1>/dev/null 2>/dev/null || { echo "Launch from root directory" exit 1 } -read -r -p "Type the version number (e.g. 2.1.3 or 2.2b): " version +# Guess version number: +branch="$(git status | grep "On branch" | awk '{print $3}')" +for((i=0;;i++)) +do + guess="${branch#v}.$i" + if ! git tag | grep -q "^v${guess//./\\.}$" ; then + echo "Guessed next version: ${guess}" + break; + fi +done + +case "$branch" in +(v2.?*) + read -r -p "Type the version number (default: ${guess}): " version + case "$version" in + ("") + version="$guess" + esac + ;; +(*) + read -r -p "Type the version number (e.g. 2.1.3 or 2.2b): " version + ;; +esac + case "$version" in (2.?*) @@ -67,10 +103,12 @@ if test "$(git tag -l | awk '{if($1=="'v$version'")print "yes"}')" == yes ; then exit 1 fi +echo "checking out branch v$shortversion" +git checkout v$shortversion + set -e if ! test "$VALIDATED" ; then - echo "checking out branch v$shortversion" - git checkout v$shortversion + update_changelog CHANGES/v$shortversion.txt $version "coming soon" echo msg="Travis tests for v$version @@ -78,10 +116,12 @@ if ! test "$VALIDATED" ; then echo "Now I will add an empty commit and push the result to origin" echo "I will use the following commands:" echo "***" + echo "git add CHANGES/v$shortversion.txt" echo "git commit --allow-empty -m \"$msg\"" echo "git push origin v$shortversion" echo "***" confirm || exit + git add CHANGES/v$shortversion.txt git commit --allow-empty -m "$msg" git push origin v$shortversion echo @@ -93,6 +133,7 @@ if ! test "$VALIDATED" ; then echo " http://plumed.github.io/doc-v$shortversion" echo "In case of success, relaunch this script as \"./release.sh --validated\"" else + update_changelog CHANGES/v$shortversion.txt $version "$(date '+%b %e, %Y' | sed 's/ / /g')" { grep \# VERSION echo $version -- GitLab