Use "sort -V" for tags when building docs

The docs script changes its behavior when running on the "latest
release tag" -- it prepares to publish the docs at the primary
location, rather than in a subdirectory.  It used "sort -n", or
a numeric sort, of all tags to determine whether the current tag
was the latest.  This would fail to sort "0.11.0" after "0.9.0".

This changes the script to use a version number sort which
recognizes that difference.

As for comptability with other version number formats: it is
compatible with year.date formats (though the script ignores those
for client libraries).  And versions with letters in them (ie,
pre-release versions) are already filtered out (a pre-release can
never be the latest released tag).

Change-Id: I6bba9bbc97b8c8e635d1b88835129113485baf21
This commit is contained in:
James E. Blair 2013-08-26 10:09:35 -07:00
parent 26e4b9ffc3
commit 50e1f72c6f

View File

@ -41,11 +41,11 @@ elif `echo $ZUUL_REFNAME | grep refs/tags/ >/dev/null` ; then
if echo $ZUUL_PROJECT | grep 'python-.*client' ; then
# This is a hack to ignore the year.release tags in python-*client
# projects.
LATEST=`git tag | sed -n -e '/^2012\..*$/d' -e '/^\([0-9]\+\.\?\)\+$/p' | sort -n | tail -1`
LATEST=`git tag | sed -n -e '/^2012\..*$/d' -e '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1`
else
# Take all tags of the form (number.)+, sort them, then take the
# largest
LATEST=`git tag | sed -n '/^\([0-9]\+\.\?\)\+$/p' | sort -n | tail -1`
LATEST=`git tag | sed -n '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1`
fi
if [ "$TAG" = "$LATEST" ] ; then
# Copy the docs into a subdir if this is a tagged build