Browse Source

HPCC-24195 Publish helm charts automatically when tagging platform

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 years ago
parent
commit
5d77ab97e2
3 changed files with 72 additions and 27 deletions
  1. 30 3
      cmake_modules/go_gold.sh
  2. 28 3
      cmake_modules/go_rc.sh
  3. 14 21
      cmake_modules/parse_hpcc_chart.sh

+ 30 - 3
cmake_modules/go_gold.sh

@@ -6,12 +6,11 @@
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
 . $SCRIPT_DIR/parse_cmake.sh
+. $SCRIPT_DIR/parse_hpcc_chart.sh
+
 if [ -e pom.xml ] ; then
   . $SCRIPT_DIR/parse_hpcc_pom.sh
 fi
-if [ -e Chart.yaml ] ; then
-  . $SCRIPT_DIR/parse_hpcc_chart.sh
-fi
 
 sync_git
 parse_cmake
@@ -51,6 +50,10 @@ for f in ${HPCC_PROJECT}; do
 done
 
 update_version_file release $HPCC_POINT $NEW_SEQUENCE
+if [ -e helm/hpcc/Chart.yaml ] ; then
+  update_chart_file helm/hpcc/Chart.yaml release $HPCC_POINT $NEW_SEQUENCE
+fi
+
 HPCC_MATURITY=release
 HPCC_SEQUENCE=$NEW_SEQUENCE
 set_tag
@@ -62,3 +65,27 @@ doit "git push $REMOTE $GIT_BRANCH $FORCE"
 
 # tag it
 do_tag
+
+if [ -e helm/hpcc/Chart.yaml ] ; then
+  # We publish any tagged version of helm chart to the helm-chart repo
+  # but only copy helm chart sources across for "latest stable" version
+
+  HPCC_DIR="$( pwd )"
+  pushd ../helm-chart 2>&1 > /dev/null
+  doit "git fetch $REMOTE"
+  doit "git merge --ff-only $REMOTE/master"
+  doit "git submodule update --init --recursive"
+  HPCC_PROJECTS=hpcc-helm
+  HPCC_NAME=HPCC
+  if [[ "$HPCC_MAJOR" == "7" ]] && [[ "$HPCC_MINOR" == "8" ]] ; then
+    doit rm -rf ./helm
+    doit cp -rf $HPCC_DIR/helm ./helm 
+  fi
+  cd docs
+  doit helm package ${HPCC_DIR}/helm/hpcc/
+  doit helm repo index . --url https://hpcc-systems.github.io/helm-chart
+  
+  doit "git commit -a -s -m \"$HPCC_NAME Helm Charts $HPCC_SHORT_TAG Release Candidate $HPCC_SEQUENCE\""
+  doit "git push $REMOTE master $FORCE"
+  popd
+fi

+ 28 - 3
cmake_modules/go_rc.sh

@@ -6,12 +6,11 @@
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
 . $SCRIPT_DIR/parse_cmake.sh
+. $SCRIPT_DIR/parse_hpcc_chart.sh
+
 if [ -e pom.xml ] ; then
   . $SCRIPT_DIR/parse_hpcc_pom.sh
 fi
-if [ -e Chart.yaml ] ; then
-  . $SCRIPT_DIR/parse_hpcc_chart.sh
-fi
 
 sync_git
 parse_cmake
@@ -43,6 +42,9 @@ if [ "$HPCC_MATURITY" = "closedown" ] ; then
   doit "git checkout $GIT_BRANCH"
   doit "git submodule update --init --recursive"
   update_version_file closedown $((NEW_POINT+1)) 0 $NEW_MINOR
+  if [ -e helm/hpcc/Chart.yaml ] ; then
+    update_chart_file helm/hpcc/Chart.yaml closedown $HPCC_POINT $NEW_SEQUENCE
+  fi
   doit "git add $VERSIONFILE"
   doit "git commit -s -m \"Split off $HPCC_MAJOR.$NEW_MINOR.$NEW_POINT\""
   doit "git push $REMOTE"
@@ -65,6 +67,10 @@ else
 fi
 
 update_version_file rc $NEW_POINT $NEW_SEQUENCE $NEW_MINOR
+if [ -e helm/hpcc/Chart.yaml ] ; then
+  update_chart_file helm/hpcc/Chart.yaml rc $HPCC_POINT $NEW_SEQUENCE
+fi
+
 HPCC_MATURITY=rc
 HPCC_SEQUENCE=$NEW_SEQUENCE
 HPCC_MINOR=$NEW_MINOR
@@ -78,3 +84,22 @@ doit "git push $REMOTE $GIT_BRANCH $FORCE"
 
 # tag it
 do_tag
+
+if [ -e helm/hpcc/Chart.yaml ] ; then
+  # We publish any tagged version of helm chart to the helm-chart repo
+  # but only copy helm chart sources across for "latest stable" version
+  HPCC_DIR="$( pwd )"
+  pushd ../helm-chart 2>&1 > /dev/null
+  doit "git fetch $REMOTE"
+  doit "git merge --ff-only $REMOTE/master"
+  doit "git submodule update --init --recursive"
+  HPCC_PROJECTS=hpcc-helm
+  HPCC_NAME=HPCC
+  cd docs
+  doit helm package ${HPCC_DIR}/helm/hpcc/
+  doit helm repo index . --url https://hpcc-systems.github.io/helm-chart
+  
+  doit "git commit -a -s -m \"$HPCC_NAME Helm Charts $HPCC_SHORT_TAG Release Candidate $HPCC_SEQUENCE\""
+  doit "git push $REMOTE master $FORCE"
+  popd
+fi

+ 14 - 21
cmake_modules/parse_hpcc_chart.sh

@@ -4,18 +4,12 @@
 #
 set -e
 
-VERSIONFILE=Chart.yaml
-if [ ! -f $VERSIONFILE ]; then
-  echo "Expected $VERSIONFILE not found"
-  exit 2
-fi
-
-
-function parse_cmake()
+function parse_chart()
 {
-  HPCC_PROJECT=$(grep -m1 '^name:' $VERSIONFILE | sed "s/^name: *//")
+  local _chart=$1
+  HPCC_PROJECT=$(grep -m1 '^name:' $_chart | sed "s/^name: *//")
   HPCC_NAME="Helm Chart for $HPCC_PROJECT"
-  HPCC_VERSION=$(grep -m1 '^version:' $VERSIONFILE | sed "s/^version: *//")
+  HPCC_VERSION=$(grep -m1 '^version:' $_chart | sed "s/^version: *//")
 
   HPCC_MAJOR=$(echo $HPCC_VERSION | awk 'BEGIN {FS="[.-]"}; {print $1};')
   HPCC_MINOR=$(echo $HPCC_VERSION | awk 'BEGIN {FS="[.-]"}; {print $2};')
@@ -45,17 +39,16 @@ function parse_cmake()
     echo "-- possibly on branch using old versioning scheme"
     exit 2
   fi
-
-
 }
 
-function update_version_file()
+function update_chart_file()
 {
     # Update the Chart.yaml file
-    local _new_maturity=$1
-    local _new_point=$2
-    local _new_sequence=$3
-    local _new_minor=$4
+    local _chart=$1
+    local _new_maturity=$2
+    local _new_point=$3
+    local _new_sequence=$4
+    local _new_minor=$5
     if [ -z "$_new_minor" ] ; then
       _new_minor=$HPCC_MINOR
     fi
@@ -69,18 +62,18 @@ function update_version_file()
       echo sed -E \
        -e "s/^version: .*$/version: $_v/" \
        -e "s/^appVersion: .*$/appVersion: $_v/" \
-       -i.bak $VERSIONFILE
+       -i.bak $_chart
     fi
     if [ -z "$DRYRUN" ] ; then 
       sed -E \
        -e "s/^version: .*$/version: $_v/" \
        -e "s/^appVersion: .*$/appVersion: $_v/" \
-       -i.bak $VERSIONFILE
-       cat $VERSIONFILE
+       -i.bak $_chart
+       cat $_chart
     else
       sed -E \
        -e "s/^version: .*$/version: $_v/" \
        -e "s/^appVersion: .*$/appVersion: $_v/" \
-       $VERSIONFILE
+       $_chart
     fi
 }