瀏覽代碼

HPCC-21493 Automate build tagging process

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 年之前
父節點
當前提交
575c687eae
共有 6 個文件被更改,包括 332 次插入0 次删除
  1. 14 0
      cmake_modules/extract_tag.sh
  2. 58 0
      cmake_modules/go_gold.sh
  3. 71 0
      cmake_modules/go_rc.sh
  4. 178 0
      cmake_modules/parse_cmake.sh
  5. 10 0
      cmake_modules/tag_build.sh
  6. 1 0
      version.cmake

+ 14 - 0
cmake_modules/extract_tag.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# Generate the expected version tag(s) corresponding to the settings in version.cmake
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+. $SCRIPT_DIR/parse_cmake.sh
+
+parse_cmake
+
+for f in ${HPCC_PROJECT} ; do
+  set_tag $f
+  echo $HPCC_LONG_TAG
+done

+ 58 - 0
cmake_modules/go_gold.sh

@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Automatically tag an existing release candidate build as gold
+#
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+. $SCRIPT_DIR/parse_cmake.sh
+
+sync_git
+parse_cmake
+
+NEW_SEQUENCE=1
+
+if [ "$HPCC_MATURITY" != "rc" ] ; then
+  if [ "$HPCC_MATURITY" = "release" ] ; then
+    NEW_SEQUENCE=$((HPCC_SEQUENCE+1))
+    if [ -z "$RETAG" ] ; then
+      echo "Current version is already at release level. Specify --retag to create $HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT-$NEW_SEQUENCE"
+      exit 2
+    fi
+  else
+    echo "Current version should be at rc level to go gold"
+    exit 2
+  fi
+fi
+if (( "$HPCC_POINT" % 2 == 1 )) ; then
+  echo "Current version should have even point version to go gold"
+  exit 2
+fi
+if [ "$GIT_BRANCH" != "candidate-$HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT" ]; then
+  echo "Current branch should be candidate-$HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT"
+  exit 2
+fi
+
+for f in ${HPCC_PROJECT}; do
+  set_tag $f
+  if [ $(git rev-parse HEAD) != $(git rev-parse $HPCC_LONG_TAG) ] ; then 
+    if [ -z "$IGNORE" ] ; then
+      git diff $HPCC_LONG_TAG
+      echo "There are changes on this branch since $HPCC_LONG_TAG. Use --ignore if you still want to tag Gold"
+      exit 2
+    fi
+  fi
+done
+
+update_version_file release $HPCC_POINT $NEW_SEQUENCE
+HPCC_MATURITY=release
+HPCC_SEQUENCE=$NEW_SEQUENCE
+set_tag
+
+# Commit the change
+doit "git add $VERSIONFILE"
+doit "git commit -s -m \"$HPCC_NAME $HPCC_SHORT_TAG Gold\""
+doit "git push $REMOTE $GIT_BRANCH $FORCE"
+
+# tag it
+do_tag

+ 71 - 0
cmake_modules/go_rc.sh

@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# Automatically tag the first rc for a new point release
+#
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+. $SCRIPT_DIR/parse_cmake.sh
+
+sync_git
+parse_cmake
+
+if [ "$HPCC_MATURITY" = "closedown" ] ; then
+  if (( "$HPCC_POINT" % 2 != 1 )) ; then
+    if [ "$HPCC_POINT" = "0" ] ; then
+      # special case when creating new minor release
+      NEW_POINT=0
+      if (( "$HPCC_MINOR" % 2 == 1 )) ; then
+        NEW_MINOR=$((HPCC_MINOR+1))
+      else
+        echo "A closedown version should have an odd point or minor version to create a new rc"
+        exit 2
+      fi
+    else
+      echo "A closedown version should have an odd point version to create a new rc"
+      exit 2
+    fi
+  else
+    NEW_POINT=$((HPCC_POINT+1))
+  fi
+  if [ "$GIT_BRANCH" != "candidate-$HPCC_MAJOR.$HPCC_MINOR.x" ]; then
+    echo "Current branch should be candidate-$HPCC_MAJOR.$HPCC_MINOR.x"
+    exit 2
+  fi
+  doit "git checkout -b candidate-$HPCC_MAJOR.$HPCC_MINOR.$NEW_POINT"
+  doit "git checkout $GIT_BRANCH"
+  doit "git submodule update --init --recursive"
+  update_version_file closedown $((NEW_POINT+1)) 0
+  doit "git add $VERSIONFILE"
+  doit "git commit -s -m \"Split off $HPCC_MAJOR.$HPCC_MINOR.$NEW_POINT\""
+  doit "git push $REMOTE"
+  GIT_BRANCH=candidate-$HPCC_MAJOR.$HPCC_MINOR.$NEW_POINT
+  doit "git checkout $GIT_BRANCH"
+  doit "git submodule update --init --recursive"
+  NEW_SEQUENCE=1
+else
+  if [ "$HPCC_MATURITY" != "rc" ] ; then
+    echo "Current branch should have closedown or rc maturity"
+    exit 2
+  fi  
+  if [ "$GIT_BRANCH" != "candidate-$HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT" ]; then
+    echo "Current branch should be candidate-$HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT"
+    exit 2
+  fi
+  NEW_POINT=$HPCC_POINT
+  NEW_SEQUENCE=$((HPCC_SEQUENCE+1))
+fi
+
+update_version_file rc $NEW_POINT $NEW_SEQUENCE $NEW_MINOR
+HPCC_MATURITY=rc
+HPCC_SEQUENCE=$NEW_SEQUENCE
+HPCC_POINT=$NEW_POINT
+set_tag
+
+# Commit the change
+doit "git add $VERSIONFILE"
+doit "git commit -s -m \"$HPCC_NAME $HPCC_SHORT_TAG Release Candidate $HPCC_SEQUENCE\""
+doit "git push $REMOTE $GIT_BRANCH $FORCE"
+
+# tag it
+do_tag

+ 178 - 0
cmake_modules/parse_cmake.sh

@@ -0,0 +1,178 @@
+#!/bin/bash
+#
+# Common utilities used by tools for automating tagging and release
+#
+
+#We want any failures to be fatal
+
+set -e
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+REMOTE=origin
+FORCE=
+DRYRUN=
+IGNORE=
+RETAG=
+VERBOSE=
+VERSIONFILE=version.cmake
+if [ ! -f $VERSIONFILE ]; then
+  VERSIONFILE=$SCRIPT_DIR/../version.cmake
+fi
+
+POSITIONAL=()
+while [[ $# -gt 0 ]]
+do
+  key="$1"
+  case $key in
+    -f|--force)
+    FORCE=-f
+    shift
+    ;;
+    -i|--ignore)
+    IGNORE=$1
+    shift
+    ;;
+    -v|--verbose)
+    VERBOSE=$1
+    shift
+    ;;
+    --retag)
+    RETAG=$1
+    shift
+    ;;
+    -d|--dryrun)
+    DRYRUN=$1
+    shift
+    ;;
+    -r|--remote)
+    if [ $# -eq 1 ] ; then
+      echo "$1 option requires an argument"
+      exit 2
+    fi
+    REMOTE="$2"
+    shift 
+    shift
+    ;;
+    *)    # unknown option
+    POSITIONAL+=("$1") # save it in an array for later
+    shift # past argument
+    ;;
+  esac
+done
+set -- "${POSITIONAL[@]}" # restore positional parameters
+
+if [ "$#" -ge 1 ] ; then
+  VERSIONFILE=$1
+  shift 1
+fi
+if [ ! -f $VERSIONFILE ]; then
+  echo "File $VERSIONFILE not found"
+  exit 2
+fi
+
+GIT_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
+
+# brute-force way to read cmake values by "parsing" the line that sets them
+# note that this makes some assumptions about how the version.cmake is laid out!
+
+function extract()
+{
+    local _file=$1
+    local _name=$2
+    local _search=$2
+    local _result=`grep -i "set *( *$_search " $_file | sed "s/^ *//" | awk -F "[ \")(]*" '{ print $3 }' -`
+    eval "$_name='$_result'"
+}
+
+function parse_cmake()
+{
+    extract $VERSIONFILE HPCC_NAME
+    extract $VERSIONFILE HPCC_PROJECT
+    extract $VERSIONFILE HPCC_MAJOR
+    extract $VERSIONFILE HPCC_MINOR
+    extract $VERSIONFILE HPCC_POINT
+    extract $VERSIONFILE HPCC_MATURITY
+    extract $VERSIONFILE HPCC_SEQUENCE
+
+    if [ -z $HPCC_NAME ] ; then
+      if [ "$HPCC_PROJECT" == "community" ] ; then
+        HPCC_NAME="Community Edition"
+      else
+        HPCC_NAME="Enterprise Edition"
+      fi
+    fi
+}
+
+function doit()
+{
+    if [ -n "$VERBOSE" ] || [ -n "$DRYRUN" ] ; then echo $1 ; fi
+    if [ -z "$DRYRUN" ] ; then eval $1 ; fi
+}
+
+function set_tag()
+{
+    local _prefix=$1
+    local _maturity=$HPCC_MATURITY
+    if [ "$HPCC_MATURITY" = "release" ]; then
+      _maturity=
+    fi
+    HPCC_SHORT_TAG=$HPCC_MAJOR.$HPCC_MINOR.$HPCC_POINT-$_maturity$HPCC_SEQUENCE
+    HPCC_LONG_TAG=${_prefix}_$HPCC_SHORT_TAG
+}
+
+function update_version_file()
+{
+    # Update the version.cmake file
+    local _new_maturity=$1
+    local _new_point=$2
+    local _new_sequence=$3
+    local _new_minor=$4
+    if [ -z "$_new_minor" ] ; then
+      _new_minor=$HPCC_MINOR
+    fi
+    
+    if [ -n "$VERBOSE" ] ; then
+      echo sed -E \
+       -e "\"s/HPCC_MINOR +$HPCC_MINOR *)/HPCC_MINOR $_new_minor )/\"" \
+       -e "\"s/HPCC_POINT +$HPCC_POINT *)/HPCC_POINT $_new_point )/\"" \
+       -e "\"s/HPCC_SEQUENCE +$HPCC_SEQUENCE *)/HPCC_SEQUENCE $_new_sequence )/\"" \
+       -e "\"s/HPCC_MATURITY +\"$HPCC_MATURITY\" *)/HPCC_MATURITY \"$_new_maturity\" )/\"" \
+       -i .bak $VERSIONFILE 
+    fi
+    if [ -z "$DRYRUN" ] ; then 
+      sed -E \
+       -e "s/HPCC_MINOR +$HPCC_MINOR *)/HPCC_MINOR $_new_minor )/" \
+       -e "s/HPCC_POINT +$HPCC_POINT *)/HPCC_POINT $_new_point )/" \
+       -e "s/HPCC_SEQUENCE +$HPCC_SEQUENCE *)/HPCC_SEQUENCE $_new_sequence )/" \
+       -e "s/HPCC_MATURITY +\"$HPCC_MATURITY\" *)/HPCC_MATURITY \"$_new_maturity\" )/" \
+       -i .bak $VERSIONFILE
+       cat $VERSIONFILE
+    else
+      sed -E \
+       -e "s/HPCC_MINOR +$HPCC_MINOR *)/HPCC_MINOR $_new_minor )/" \
+       -e "s/HPCC_POINT +$HPCC_POINT *)/HPCC_POINT $_new_point )/" \
+       -e "s/HPCC_SEQUENCE +$HPCC_SEQUENCE *)/HPCC_SEQUENCE $_new_sequence )/" \
+       -e "s/HPCC_MATURITY +\"$HPCC_MATURITY\" *)/HPCC_MATURITY \"$_new_maturity\" )/" \
+       $VERSIONFILE
+    fi
+}
+
+function do_tag()
+{
+    for f in ${HPCC_PROJECT}; do
+      set_tag $f
+      if [ "$FORCE" = "-f" ] ; then
+        doit "git tag -d $HPCC_LONG_TAG"
+      fi
+      doit "git tag $HPCC_LONG_TAG"
+      doit "git push $REMOTE $HPCC_LONG_TAG $FORCE"
+    done
+}
+
+function sync_git()
+{
+    doit "git fetch $REMOTE"
+    doit "git merge --ff-only $REMOTE/$GIT_BRANCH"
+    doit "git submodule update --init --recursive"
+}

+ 10 - 0
cmake_modules/tag_build.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+#
+# Automatically tag a build and push the tags, from the information in version.cmake
+#
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+. $SCRIPT_DIR/parse_cmake.sh
+
+do_tag

+ 1 - 0
version.cmake

@@ -1,6 +1,7 @@
 ###
 ##  Version Information
 ###
+set ( HPCC_NAME "Community Edition" )
 set ( HPCC_PROJECT "community" )
 set ( HPCC_MAJOR 6 )
 set ( HPCC_MINOR 4 )