From 1beabfcce818f3689afa9eb2b50777290d9f5a39 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 17 Jun 2015 15:59:27 -0400 Subject: [PATCH] Move releaser to buildkit --- tools/scripts/releaser/releaser | 384 ----------------------- tools/scripts/releaser/releaser.conf.txt | 37 --- tools/scripts/releaser/releaser_json.php | 73 ----- tools/scripts/releaser/self-update | 16 - 4 files changed, 510 deletions(-) delete mode 100755 tools/scripts/releaser/releaser delete mode 100644 tools/scripts/releaser/releaser.conf.txt delete mode 100644 tools/scripts/releaser/releaser_json.php delete mode 100644 tools/scripts/releaser/self-update diff --git a/tools/scripts/releaser/releaser b/tools/scripts/releaser/releaser deleted file mode 100755 index 41b5cae905..0000000000 --- a/tools/scripts/releaser/releaser +++ /dev/null @@ -1,384 +0,0 @@ -#!/bin/bash -set -e - -confdir=$(dirname $0) -start_point="$1" -version="$2" -first_act="$3" -distmaker_tgt=all - -if [ ! -f "$confdir/releaser.conf" ]; then - echo - echo "Missing configuration file. Please copy $confdir/releaser.conf.txt to $confdir/releaser.conf and edit it." - exit 1 -fi -source "$confdir/releaser.conf" - -if [ -z "$start_point" -o -z "$version" -o -z "$first_act" ]; then - echo - echo "Usage:" - echo " $0 --build" - echo " $0 --publish" - echo " $0 --update" - echo " $0 --clean" - echo " $0 --build --publish --update --clean [[ORDER SIGNIFICANT]]" - echo "Arguments:" - echo " is a branch name (e.g. \"master\")" - echo " is Civi release (e.g. \"4.3.beta2\"); it will become a tag name" - exit 2 -fi - -if [ "`echo -n $version | tr -d 0-9.`" = '' ]; then - is_stable=1 -else - is_stable= -fi - -################################################# -## Prompt user for input, and set the named global variable to the selected value. -## usage: prompt variable_name [prompt message] [option][option][...] -## example: -## prompt your_name "What's your name?" Bob Sally John Mary -function prompt() { - - local variable_name=$1 - shift - - local prompt - local option_key - local input - local is_answered - - prompt=$1 - shift - - # Initialize a counter for the options array. - option_key=1 - # Add all options to the options array. - for option in "$@"; do - prompt="${prompt}\n${option_key}: ${option}"; - options[$option_key]=$option - let "option_key=option_key+1" - done - - # As long as we don't have a valid selection, keep prompting. - while [[ -z "$input" ]]; do - echo -e $prompt - # If this is a second attempt, remind the user to select a valid value. - if [ $is_answered ]; then - echo "Please enter one of the provided integer values." - fi - read input - is_answered=1 - if [[ "$input" > "$option_key" || "$input" < "1" ]]; then - # Unset any invalid input. - unset input - fi - done - # Set the named global variable to the selected string value. - eval $variable_name=\${options[$input]} -} - -################################################# -## Git setup -function do_git_config() { - git config --global user.name "$git_author_name" - git config --global user.email "$git_author_email" -} - -################################################# -## Create build directories; checkout repos -function do_mk_project() { - for dir in \ - "$workdir" \ - "$workdir/$version" \ - "$workdir/$version/export" \ - "$workdir/$version/gen" \ - "$workdir/$version/tarballs" \ - "$workdir/$version/tmp" - do - if [ ! -d "$dir" ]; then - mkdir -p "$dir" - fi - done - - $cmd_gitify all "$git_base_url" "$workdir/$version/export" --l10n --branch "$start_point" --skip-gencode -} - -################################################# -## Tag all repos -function do_git_tag() { - cd $workdir/$version - for dir in export export/joomla export/WordPress export/packages ; do - pushd $dir - git checkout "$start_point" - git tag "$version" - popd - done - - for drupal_ver in 6.x 7.x ; do - pushd export/drupal - git checkout "${drupal_ver}-${start_point}" - git tag "${drupal_ver}-${version}" - popd - done -} - -################################################# -## Publish tags via git -function do_git_tag_push() { - cd $workdir/$version - for dir in export export/joomla export/WordPress export/packages ; do - pushd $dir - git push -f origin "$version" - popd - done - - for drupal_ver in 6.x 7.x ; do - pushd export/drupal - git push -f origin "${drupal_ver}-${version}" - popd - done -} - -################################################# -## Build -function do_distmaker() { - cd $workdir/$version - - ## Determine SCM revision of main codebase - pushd "export" - rev=$(git rev-parse HEAD | head -c10) - popd - - # create the distmaker.conf file - echo " - DM_SOURCEDIR=$workdir/$version/export - DM_GENFILESDIR=$workdir/$version/gen - DM_TMPDIR=$workdir/$version/tmp - DM_TARGETDIR=$workdir/$version/tarballs - DM_PHP=$cmd_php - DM_RSYNC=$cmd_rsync - 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 - mkdir -p $workdir/$version/export/default - echo "" > $workdir/$version/export/default/civicrm.settings.php - - # create a minimal settings_location.php file - echo "" > $workdir/$version/export/settings_location.php - - # run the exported distmaker - cd $workdir/$version/export/distmaker - ./distmaker.sh $distmaker_tgt > $workdir/$version/build.log -} - -################################################# -## Publish files -function do_publish() { - # publish to sf.net - pushd $workdir/$version/tarballs - - $cmd_md5sum *.tar.gz *.tgz *.zip > civicrm-$version.MD5SUMS - echo $gpg_pass | $cmd_gpg --armor --batch --passphrase-fd 0 --sign civicrm-$version.MD5SUMS - - if [ "$is_stable" ]; then - echo mkdir ${publish_stable_dir}/$version | $cmd_sftp ${publish_ssh} - $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_stable_dir}/$version - else - echo mkdir ${publish_latest_dir}/$version | $cmd_sftp ${publish_ssh} - $cmd_rsync -aP --exclude='*starterkit.tgz' *.tar.gz *.zip *MD5SUMS* ${publish_ssh}:${publish_latest_dir}/$version - fi - - mv *.tar.gz *.tgz *.zip *MD5SUMS* $build_dest - - popd -} - -################################################# -## Publish version data to versions.json -function do_publish_versions() { - # Turn off command echoing, because it makes input prompts hard to read. - set +x - - # Quit if versions.json is missing. - if [ ! -f $latest/versions.json ]; then - echo "Cannot find $latest/versions.json, so not updating it." - return 0; - fi - - major_version=`echo $version | awk -F '.' '{print $1"."$2}'` - json=`cat $latest/versions.json` - - # Ask for the status of this release. - prompt status "What is the status of the major version for this release?" testing stable lts - - # Rather complex steps to reconcile new release status with previous releases. - if [[ "$status" == "lts" ]]; then - # If it's LTS, ask what status to use for the current LTS, if any. - older_lts_version=$(php -r " - require 'releaser_json.php'; - print_previous_status_version('$json', 'lts', '$major_version'); - ") - if [[ -n "$older_lts_version" ]]; then - prompt new_status_for_older_lts "Since this release is lts, what should be the new status for the current lts version ($older_lts_version)?" lts eol - # Assign the selected status to the current LTS version. - json=$(php -r " - require 'releaser_json.php'; - update_version_status('$json', '$older_lts_version', '$new_status_for_older_lts'); - ") - fi - elif [[ "$status" == "stable" ]]; then - # If it's stable, ask what status to use for the current stable, if any. - older_stable_version=$(php -r " - require 'releaser_json.php'; - print_previous_status_version('$json', 'stable', '$major_version'); - ") - if [[ -n "$older_stable_version" ]]; then - prompt new_status_for_older_stable "Since this release is stable, what should be the new status for the current stable version ($older_stable_version)?" stable lts eol - # Assign the selected status to the current stable version. - json=$(php -r " - require 'releaser_json.php'; - update_version_status('$json', '$older_stable_version', '$new_status_for_older_stable'); - ") - if [[ "$new_status_for_older_stable" == "lts" ]]; then - # But now, if we've bumped 'stable' to 'lts', we have to ask what status - # to use for an older existing LTS release, if any. - older_lts_version=$(php -r " - require 'releaser_json.php'; - print_previous_status_version('$json', 'lts', '$older_stable_version'); - ") - if [[ -n "$older_lts_version" ]]; then - prompt new_status_for_older_lts "Since $older_stable_version is now lts, what should be the new status for the current lts version ($older_lts_version)?" lts eol - # Assign the selected status to the older existing LTS release. - json=$(php -r " - require 'releaser_json.php'; - update_version_status('$json', '$older_lts_version', '$new_status_for_older_lts'); - ") - fi - fi - fi - fi - - # Ask if this is a security release. - prompt is_security "Is this a security release?" Yes No - if [[ "$is_security" == "Yes" ]]; then - is_security="true" - else - is_security="false" - fi - - # Update status for this release's major version. - json=$(php -r " - require 'releaser_json.php'; - update_version_status('$json', '$major_version', '$status'); - ") - - # Add the new release to JSON data. - release_date=$(date +%Y-%m-%d); - # Create json string for release properties; `tr` is just to let us use - # (json-invalid) single quotes, which are easier to read in bash. - release_json=$(echo "{'version':'$version','date':'$release_date','security':'$is_security'}" | tr \' \") - json=$(php -r" - require 'releaser_json.php'; - add_release('$json', '$major_version', '$release_json'); - ") - - # Write modified JSON data to versions.json. - echo $json > $latest/versions.json -} - -################################################# -## 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() { - cd $workdir/$version - rm -rf export gen tmp tarballs tmp -} - -################################################# -## Main - -## Refactoring note: this used to be one monolithic script - -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 - do_publish_versions - set +x - ;; - --update) - set +x - do_update - ;; - --clean) - set -ex - do_cleanup - set +x - ;; - *) - echo "unrecognized: $ACT" - ;; - esac -done - diff --git a/tools/scripts/releaser/releaser.conf.txt b/tools/scripts/releaser/releaser.conf.txt deleted file mode 100644 index 927a94a4e8..0000000000 --- a/tools/scripts/releaser/releaser.conf.txt +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -## The GIT repo where we can find branches and create tags -## Note: Choose https or SSH depending on whether you've -## configured HTTP credential cache or SSH keys. -#git_base_url=https://github.com/civicrm -#git_base_url=git@github.com:civicrm - -## Warning: This will be saved to the current user's ~/.gitconfig; should match gpg key -git_author_name="CiviCRM" -git_author_email="info@civicrm.org" - -## Local web directory for publishing tarballs, md5sums, etc -build_dest='/tmp/www/download.civicrm.org/public' - -## Local web directory for publishing the latest version number -latest='/tmp/www/latest.civicrm.org/public' - -## Local directory for build operations -workdir='/tmp/www/download.civicrm.org/workdir' - -## Passphrase for gpg signing key -gpg_pass="top-secret" - -## Remote web directory for publishing tarballs, md5sums, etc -publish_ssh="localhost" -publish_stable_dir=/tmp/www/publish/stable -publish_latest_dir=/tmp/www/publish/latest - -## Paths to miscellaneous executables -cmd_gitify=/Applications/MAMP/htdocs/sites/all/modules/civicrm/bin/gitify -cmd_gpg=gpg -cmd_md5sum=md5sum -cmd_php=php -cmd_rsync=rsync -cmd_sftp=sftp -cmd_zip=zip diff --git a/tools/scripts/releaser/releaser_json.php b/tools/scripts/releaser/releaser_json.php deleted file mode 100644 index dff8019bb5..0000000000 --- a/tools/scripts/releaser/releaser_json.php +++ /dev/null @@ -1,73 +0,0 @@ - " - echo "example: $0 civicrm master" - exit 1 -fi - -wget -O gitify "https://raw.github.com/${git_user}/civicrm-core/${git_branch}/bin/gitify" -wget -O releaser "https://raw.github.com/${git_user}/civicrm-core/${git_branch}/tools/scripts/releaser/releaser" -wget -O releaser.conf.txt "https://raw.github.com/${git_user}/civicrm-core/${git_branch}/tools/scripts/releaser/releaser.conf.txt" -- 2.25.1