Skip to content
Snippets Groups Projects
Commit 13b90eac authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Improved ./release.sh

Some more automatization of relase:
1. Version number is guessed based on current branch
2. Date in changelog is automatically set
parent 8c4b8663
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment