BUILD: scripts: add an automatic mode for publish-release

Passing "-a" will make it easier to automatically create archives from
tagged repositories. It doesn't ask any question and doesn't return an
error when the current branch is not tagged nor if the release already
exists.
This commit is contained in:
Willy Tarreau 2017-06-09 15:54:39 +02:00
parent 600cb57450
commit 7ca88159a1

View File

@ -8,12 +8,13 @@
# - copies & compresses files, changelog & docs to the final destination # - copies & compresses files, changelog & docs to the final destination
# - shows a listing of the final file # - shows a listing of the final file
USAGE="Usage: ${0##*/} [-y] [-b branch] [-n newver] DIR" USAGE="Usage: ${0##*/} [-a] [-y] [-b branch] [-n newver] DIR"
TARGET_DIR= TARGET_DIR=
OUTPUT= OUTPUT=
SAYYES= SAYYES=
BRANCH= BRANCH=
DEVEL= DEVEL=
AUTO=
NEW= NEW=
DIR= DIR=
DOC=( ) DOC=( )
@ -34,6 +35,7 @@ quit() {
while [ -n "$1" -a -z "${1##-*}" ]; do while [ -n "$1" -a -z "${1##-*}" ]; do
case "$1" in case "$1" in
-a) AUTO=1 ; shift ;;
-y) SAYYES=1 ; shift ;; -y) SAYYES=1 ; shift ;;
-b) BRANCH="$2" ; shift 2 ;; -b) BRANCH="$2" ; shift 2 ;;
-n) NEW="$2" ; shift 2 ;; -n) NEW="$2" ; shift 2 ;;
@ -84,13 +86,19 @@ if [ "$(git diff HEAD 2>/dev/null |wc -c)" != 0 ]; then
die die
fi fi
if [ -z "$NEW" ]; then if [ -z "$NEW" -o -n "$AUTO" ]; then
NEW="$(git describe --tags HEAD --abbrev=0)"
NEW="${NEW#v}"
if [ -z "$NEW" ]; then if [ -z "$NEW" ]; then
die "Fatal: cannot determine new version, please specify it." NEW="$(git describe --tags HEAD --abbrev=0)"
NEW="${NEW#v}"
if [ -z "$NEW" ]; then
die "Fatal: cannot determine new version, please specify it."
fi
fi fi
if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then
if [ -n "$AUTO" ]; then
quit "Not tagged, nothing to do."
fi
die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?" die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?"
fi fi
fi fi
@ -117,6 +125,10 @@ if [ -z "${NEW##*-dev*}" ]; then
DEVEL="/devel" DEVEL="/devel"
fi fi
if [ -n "$AUTO" -a -e "$TARGET_DIR/src${DEVEL}/haproxy-$NEW.tar.gz.md5" ]; then
quit "Version $NEW Already released."
fi
if ! mkdir -p "$TARGET_DIR/src$DEVEL" "$TARGET_DIR/doc"; then if ! mkdir -p "$TARGET_DIR/src$DEVEL" "$TARGET_DIR/doc"; then
die "failed to create target directories." die "failed to create target directories."
fi fi
@ -129,17 +141,19 @@ case "$BRANCH" in
*) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua,SPOE}.txt ) ;; *) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua,SPOE}.txt ) ;;
esac esac
echo "Ready to produce the following files in $TARGET_DIR/ :" if [ -z "$AUTO" ]; then
echo " haproxy-$NEW.tar.gz -> src${DEVEL}/" echo "Ready to produce the following files in $TARGET_DIR/ :"
echo " CHANGELOG -> src/CHANGELOG" echo " haproxy-$NEW.tar.gz -> src${DEVEL}/"
echo " ${DOC[@]} -> doc/*{,.gz}" echo " CHANGELOG -> src/CHANGELOG"
echo echo " ${DOC[@]} -> doc/*{,.gz}"
echo
git ls-tree -l --abbrev=12 "v$NEW" -- CHANGELOG "${DOC[@]}" git ls-tree -l --abbrev=12 "v$NEW" -- CHANGELOG "${DOC[@]}"
if [ -z "$SAYYES" ]; then if [ -z "$SAYYES" ]; then
echo "Press ENTER to continue or Ctrl-C to abort now!" echo "Press ENTER to continue or Ctrl-C to abort now!"
read read
fi
fi fi
echo "Archiving sources for version $NEW ..." echo "Archiving sources for version $NEW ..."