Merge branch 'master' into recurring-activity-46
[civicrm-core.git] / tools / scripts / releaser / releaser
index b4406993eca4bbd14fc0b6de8dfef0db506e427f..08238b5a80efda23e27ef6006c8baed59a653cd9 100755 (executable)
@@ -4,6 +4,7 @@ set -e
 confdir=$(dirname $0)
 start_point="$1"
 version="$2"
+first_act="$3"
 distmaker_tgt=all
 
 if [ ! -f "$confdir/releaser.conf" ]; then
@@ -13,9 +14,15 @@ if [ ! -f "$confdir/releaser.conf" ]; then
 fi
 source "$confdir/releaser.conf"
 
-if [ -z "$version" -o -z "$start_point" ]; then
+if [ -z "$start_point" -o -z "$version" -o -z "$first_act" ]; then
   echo
-  echo "Usage: $0 <start_point> <version>"
+  echo "Usage:"
+  echo "  $0 <start_point> <version> --build"
+  echo "  $0 <start_point> <version> --publish"
+  echo "  $0 <start_point> <version> --update"
+  echo "  $0 <start_point> <version> --clean"
+  echo "  $0 <start_point> <version> --build --publish --update --clean [[ORDER SIGNIFICANT]]"
+  echo "Arguments:"
   echo "  <start_point> is a branch name (e.g. \"master\")"
   echo "  <version> is Civi release (e.g. \"4.3.beta2\"); it will become a tag name"
   exit 2
@@ -27,8 +34,6 @@ else
   is_stable=
 fi
 
-set -ex
-
 #################################################
 ## Git setup
 function do_git_config() {
@@ -52,7 +57,7 @@ function do_mk_project() {
     fi
   done
 
-  $cmd_gitify all "$git_base_url" "$workdir/$version/export" --l10n
+  $cmd_gitify all "$git_base_url" "$workdir/$version/export" --l10n --branch "$start_point" --skip-gencode
 }
 
 #################################################
@@ -112,6 +117,12 @@ function do_distmaker() {
   DM_VERSION=$version
   DM_REVISION=$rev
   DM_ZIP=$cmd_zip
+  DM_REF_CORE=${start_point}
+  DM_REF_DRUPAL=7.x-${start_point}
+  DM_REF_DRUPAL6=6.x-${start_point}
+  DM_REF_JOOMLA=${start_point}
+  DM_REF_WORDPRESS=${start_point}
+  DM_REF_PACKAGES=${start_point}
   " > $workdir/$version/export/distmaker/distmaker.conf
 
   # create a minimal civicrm.settings.php file
@@ -153,6 +164,45 @@ function do_publish() {
   echo $version > $latest/latest.txt
 }
 
+#################################################
+## Update Version Info
+function do_update() {
+  echo "VERSION UPDATE: Enter the version that comes after $version (or enter nothing to abort)"
+  read new_ver
+  if [ -n "$new_ver" ]; then
+    cd $workdir/$version/export
+    # create sql upgrade file
+    tpl="CRM/Upgrade/Incremental/sql/$new_ver.mysql.tpl"
+    if [ ! -f $tpl ]; then
+      echo "{* file to handle db changes in $new_ver during upgrade *}" > $tpl
+    fi
+    # escape regex special chars
+    arg=`echo "$version" | sed 's:[]\[\^\$\.\*\/]:\\\\&:g'`
+    for file in xml/version.xml sql/civicrm_generated.mysql; do
+      set -ex
+      git checkout $file
+      sed "s/$arg/$new_ver/" < $file > $file.tmp
+      mv $file.tmp $file
+      set +x
+    done
+    # print the diff directly to the screen
+    git diff | cat
+    echo "Push these changes? y/n"
+    read input
+    if [ "$input" = "y" ]; then
+      set -ex
+      git add  xml/version.xml sql/civicrm_generated.mysql $tpl
+      git commit -m "Update version to $new_ver"
+      git push origin "$start_point"
+      set +x
+    else
+      do_update
+    fi
+  else
+    echo "No version entered. Aborting version update."
+  fi
+}
+
 #################################################
 ## Cleanup
 function do_cleanup() {
@@ -165,10 +215,36 @@ function do_cleanup() {
 
 ## Refactoring note: this used to be one monolithic script
 
-do_git_config
-do_mk_project
-do_git_tag
-do_distmaker
-do_git_tag_push
-do_publish
-do_cleanup
+shift ## start point
+shift ## version
+for ACT in "$@" ; do
+  case "$ACT" in
+    --build)
+      set -ex
+      do_git_config
+      do_mk_project
+      do_git_tag
+      do_distmaker
+      set +x
+      ;;
+    --publish)
+      set -ex
+      do_git_tag_push
+      do_publish
+      set +x
+      ;;
+    --update)
+      set +x
+      do_update
+      ;;
+    --clean)
+      set -ex
+      do_cleanup
+      set +x
+      ;;
+    *)
+      echo "unrecognized: $ACT"
+      ;;
+  esac
+done
+