Commit 31e638ac authored by Huihui, Jonathan's avatar Huihui, Jonathan
Browse files

release automagic script

parent 9055ab1b
Loading
Loading
Loading
Loading

release.sh

0 → 100755
+78 −0
Original line number Diff line number Diff line
#!/bin/bash
set -eux
# -*- coding: utf-8 -*-
#/ Perform releases of the common package. Make sure to increment COMMON_VERSION.
#/ Usage:
#/   ./release.sh
#/
#/   release)
#/      release the ei package version based on values in COMMON_VERSION and
#/      update the docker container/image
#/   -h|-?|--help)
#/      show this help and exit


banner() {
BANNER=""                                           
BANNER="$BANNER\n  ___ ___  _ __ ___  _ __ ___   ___  _ __  "
BANNER="$BANNER\n / __/ _ \\| '_ \` _ \\| '_ \` _ \\ / _ \\| '_ \\ "
BANNER="$BANNER\n| (_| (_) | | | | | | | | | | | (_) | | | |"
BANNER="$BANNER\n \\___\\___/|_| |_| |_|_| |_| |_|\\___/|_| |_|"
BANNER="$BANNER\n               package helpers"
echo -e "$BANNER\n\n"
}

die() { 
  echo -e "\033[31mFAILURE:\033[39m $1"
  exit 1
} 
warn() { 
  echo -e "\033[33mWARNING:\033[39m $1"
} 
info() {
  echo -e "\033[32mINFO:\033[39m $1"
}
show_help() { 
  grep '^#/' "${BASH_SOURCE[0]}" | cut -c4- || \
    die "Failed to display usage information"
}
banner
while :; do
  case $1 in 
    release)
      info "Checking out develop branch."
      git checkout develop
      COMMON_VERSION=$(cat COMMON_VERSION)
      COMMON_SETUP_REGEX="s/(?<=version \= ')\d+\.\d+\.\d+/$COMMON_VERSION/g"
      COMMON_README_REGEX="s/(?<=common\=\=)\d+\.\d+\.\d+/$COMMON_VERSION/g"
      COMMON_README_ADDTL_REGEX="s/(?<=version )\d+\.\d+\.\d+/$COMMON_VERSION/g"
      COMMON_README_FILE="./README.md"
      COMMON_SETUP_FILE="src/setup.py"
      echo $COMMON_VERSION
      perl -pi.bak -e "$COMMON_SETUP_REGEX" "$COMMON_SETUP_FILE"
      perl -pi.bak -e "$COMMON_README_REGEX" "$COMMON_README_FILE"
      perl -pi.bak -e "$COMMON_README_ADDTL_REGEX" "$COMMON_README_FILE"
      #./src/upload.sh
      #./build.sh --tag "$COMMON_VERSION"
      git add src/setup.py README.md && \
      git commit -m 'bump common version'
      exit
      ;;
    -h|-\?|--help) 
      show_help
      exit
      ;;
  esac
done