Repository: cassandra-builds Updated Branches: refs/heads/master 145fa130a -> ac05c7153
Add cassandra-release scripts to repo Project: http://git-wip-us.apache.org/repos/asf/cassandra-builds/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra-builds/commit/ac05c715 Tree: http://git-wip-us.apache.org/repos/asf/cassandra-builds/tree/ac05c715 Diff: http://git-wip-us.apache.org/repos/asf/cassandra-builds/diff/ac05c715 Branch: refs/heads/master Commit: ac05c7153bb290572cf1f7a98ea9fc652ca965e4 Parents: 145fa13 Author: Michael Shuler <[email protected]> Authored: Thu Feb 16 11:50:42 2017 -0600 Committer: Michael Shuler <[email protected]> Committed: Thu Feb 16 11:50:42 2017 -0600 ---------------------------------------------------------------------- cassandra-release/README.md | 5 + cassandra-release/finish_release.sh | 221 ++++++++++++++++++++++++++++ cassandra-release/prepare_release.sh | 229 ++++++++++++++++++++++++++++++ cassandra-release/upload_bintray.sh | 22 +++ 4 files changed, 477 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra-builds/blob/ac05c715/cassandra-release/README.md ---------------------------------------------------------------------- diff --git a/cassandra-release/README.md b/cassandra-release/README.md new file mode 100644 index 0000000..d443cf8 --- /dev/null +++ b/cassandra-release/README.md @@ -0,0 +1,5 @@ +Cassandra release scripts +========================= + +For release managers of cassandra. + http://git-wip-us.apache.org/repos/asf/cassandra-builds/blob/ac05c715/cassandra-release/finish_release.sh ---------------------------------------------------------------------- diff --git a/cassandra-release/finish_release.sh b/cassandra-release/finish_release.sh new file mode 100755 index 0000000..99655c1 --- /dev/null +++ b/cassandra-release/finish_release.sh @@ -0,0 +1,221 @@ +#!/bin/bash + +##### TO EDIT ##### + +asf_username="$USER" + +# The name of remote for the asf remote in your git repo +git_asf_remote="origin" + +# Same as for .prepare_release.sh +mail_dir="$HOME/Mail" +debian_package_dir="$HOME/tmp/debian" + +# The directory for reprepro +reprepro_dir="$debian_package_dir/packages" +artifacts_svn_dir="$HOME/svn/cassandra-dist" + +################### + +asf_git_repo="http://git-wip-us.apache.org/repos/asf" +apache_host="people.apache.org" + +# Reset getopts in case it has been used previously in the shell. +OPTIND=1 + +# Initialize our own variables: +verbose=0 +fake_mode=0 + +show_help() +{ + local name=`basename $0` + echo "$name [options] <release_version> <staging_number>" + echo "" + echo "where [options] are:" + echo " -h: print this help" + echo " -v: verbose mode (show everything that is going on)" + echo " -f: fake mode, print any output but don't do anything (for debugging)" + echo "" + echo "Example: $name 2.0.3 1024" +} + +while getopts ":hvf" opt; do + case "$opt" in + h) + show_help + exit 0 + ;; + v) verbose=1 + ;; + f) fake_mode=1 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + show_help + exit 1 + ;; + esac +done + +shift $(($OPTIND-1)) + +release=$1 +staging_number=$2 +deb_release=${release/-/\~} + +if [ -z "$release" ] +then + echo "Missing argument <release_version>" + show_help + exit 1 +fi +if [ -z "$staging_number" ] +then + echo "Missing argument <staging_number>" + show_help + exit 1 +fi + +if [ "$#" -gt 2 ] +then + shift + echo "Too many arguments. Don't know what to do with '$@'" + show_help + exit 1 +fi + +# Somewhat lame way to check we're in a git repo but that will do +git log -1 &> /dev/null +if [ $? -ne 0 ] +then + echo "The current directory does not appear to be a git repository." + echo "You must run this from the Cassandra git source repository." + exit 1 +fi + +if [ "$release" == "$deb_release" ] +then + echo "Publishing release $release using staging number $staging_number" +else + echo "Publishing release $release (debian uses $deb_release) using staging number $staging_number" +fi + +# "Saves" stdout to other descriptor since we might redirect them below +exec 3>&1 4>&2 + +if [ $verbose -eq 0 ] +then + # Not verbose, redirect all ouptut to a logfile + logfile="release-${release}.log" + [ ! -e "$logfile" ] || rm $logfile + touch $logfile + exec > $logfile + exec 2> $logfile +fi + +execute() +{ + local cmd=$1 + + echo ">> $cmd" + [ $fake_mode -eq 1 ] || $cmd + if [ $? -ne 0 ] + then + echo "Error running $cmd" 1>&3 2>&4 + exit $? + fi +} + +idx=`expr index "$release" -` +if [ $idx -eq 0 ] +then + release_short=${release} +else + release_short=${release:0:$((idx-1))} +fi + +echo "Deploying artifacts ..." 1>&3 2>&4 +start_dir=$PWD +cd $artifacts_svn_dir +mkdir $release_short +cd $release_short +for type in bin src; do + for part in gz gz.md5 gz.sha1 gz.asc gz.asc.md5 gz.asc.sha1; do + echo "Downloading apache-cassandra-${release}-$type.tar.$part..." 1>&3 2>&4 + curl -O https://repository.apache.org/content/repositories/orgapachecassandra-${staging_number}/org/apache/cassandra/apache-cassandra/${release}/apache-cassandra-${release}-$type.tar.$part + done +done + +cd $start_dir + +echo "Tagging release ..." 1>&3 2>&4 +execute "git checkout $release-tentative" + +# Ugly but somehow 'execute "git tag -a cassandra-$release -m 'Apache Cassandra $release release' "' doesn't work +echo "Apache Cassandra $release release" > "_tmp_msg_" +execute "git tag -a cassandra-$release -F _tmp_msg_" +rm _tmp_msg_ +execute "git push $git_asf_remote refs/tags/cassandra-$release" +execute "git tag -d $release-tentative" +execute "git push $git_asf_remote :refs/tags/$release-tentative" + +echo "Deploying debian packages ..." 1>&3 2>&4 + +current_dir=`pwd` + +debian_series="${release_short:0:1}${release_short:2:2}x" + +execute "cd $reprepro_dir" +execute "reprepro --ignore=wrongdistribution include $debian_series $debian_package_dir/cassandra_${release}_debian/cassandra_${deb_release}_*.changes" +execute "cp -p pool/main/c/cassandra/cassandra*_${deb_release}* ${artifacts_svn_dir}/debian/pool/main/c/cassandra" +execute "cp -p ${artifacts_svn_dir}/$release_short/apache-cassandra-${release}-src.tar.gz.asc ${artifacts_svn_dir}/debian/pool/main/c/cassandra/cassandra_${deb_release}.orig.tar.gz.asc" +execute "cp -a dists/$debian_series ${artifacts_svn_dir}/debian/dists" + +execute "cd $current_dir" + +# Restore stdout/stderr (and close temporary descriptors) if not verbose +[ $verbose -eq 1 ] || exec 1>&3 3>&- 2>&4 4>&- + +mail_file="$mail_dir/mail_release_$release" +[ ! -e "$mail_file" ] || rm $mail_file + +echo "[RELEASE] Apache Cassandra $release released" > $mail_file +echo "" >> $mail_file +echo "The Cassandra team is pleased to announce the release of Apache Cassandra version $release." >> $mail_file +echo "" >> $mail_file +echo "Apache Cassandra is a fully distributed database. It is the right choice when you need scalability and high availability without compromising performance." >> $mail_file +echo "" >> $mail_file +echo " http://cassandra.apache.org/" >> $mail_file +echo "" >> $mail_file +echo "Downloads of source and binary distributions are listed in our download section:" >> $mail_file +echo "" >> $mail_file +echo " http://cassandra.apache.org/download/" >> $mail_file +echo "" >> $mail_file +series="${release_short:0:1}.${release_short:2:1}" +echo "This version is a bug fix release[1] on the $series series. As always, please pay attention to the release notes[2] and Let us know[3] if you were to encounter any problem." >> $mail_file +echo "" >> $mail_file +echo "Enjoy!" >> $mail_file +echo "" >> $mail_file +echo "[1]: (CHANGES.txt)" >> $mail_file +echo "[2]: (NEWS.txt)" >> $mail_file +echo "[3]: https://issues.apache.org/jira/browse/CASSANDRA" >> $mail_file + + +echo "Done deploying artifacts. Please make sure to:" +echo " 0) commit changes to ${artifacts_svn_dir}" +echo " 1) release artifacts from repository.apache.org" +echo " 2) wait for the artifacts to sync at http://www.apache.org/dist/cassandra/" +echo " 3) upload debian repo to bintray: ./upload_bintray.sh ${artifacts_svn_dir}/debian" +echo " 4) update the website (~/Git/hyde/hyde.py -g -s src/ -d publish/)" # TODO - this is old info and needs updating.. +echo " 5) update CQL doc if appropriate" +echo " 6) update wikipedia page if appropriate" +echo " 7) send announcement email: draft in $mail_dir/mail_release_$release, misses short links for" +echo " > CHANGES.txt: $asf_git_repo?p=cassandra.git;a=blob_plain;f=CHANGES.txt;hb=refs/tags/cassandra-$release" +echo " > NEWS.txt: $asf_git_repo?p=cassandra.git;a=blob_plain;f=NEWS.txt;hb=refs/tags/cassandra-$release" +echo " 8) update #cassandra topic on irc (/msg chanserv op #cassandra)" +echo " 9) tweet from @cassandra" +echo " 10) release version in JIRA" +echo " 11) remove old version from people.apache.org (in /www/www.apache.org/dist/cassandra and debian)" +echo " 12) increment build.xml base.version for the next release" + http://git-wip-us.apache.org/repos/asf/cassandra-builds/blob/ac05c715/cassandra-release/prepare_release.sh ---------------------------------------------------------------------- diff --git a/cassandra-release/prepare_release.sh b/cassandra-release/prepare_release.sh new file mode 100755 index 0000000..c9d8979 --- /dev/null +++ b/cassandra-release/prepare_release.sh @@ -0,0 +1,229 @@ +#!/bin/bash + +##### TO EDIT ##### + +asf_username="$USER" +gpg_key="XXXXXXXX" + +# The name of remote for the asf remote in your git repo +git_asf_remote="origin" + +# Where you want to put the mail draft that this script generate +mail_dir="$HOME/Mail" + +# Where you want to put the debian files +debian_package_dir="$HOME/tmp/debian" + +################### + +asf_git_repo="http://git-wip-us.apache.org/repos/asf" +staging_repo="https://repository.apache.org/content/repositories" +apache_host="people.apache.org" + +# Reset getopts in case it has been used previously in the shell. +OPTIND=1 + +# Initialize our own variables: +verbose=0 +fake_mode=0 +only_deb=0 + +show_help() +{ + local name=`basename $0` + echo "$name [options] <release_version>" + echo "" + echo "where [options] are:" + echo " -h: print this help" + echo " -v: verbose mode (show everything that is going on)" + echo " -f: fake mode, print any output but don't do anything (for debugging)" + echo " -d: only build the debian package" + echo "" + echo "Example: $name 2.0.3" +} + +while getopts ":hvfd" opt; do + case "$opt" in + h) + show_help + exit 0 + ;; + v) verbose=1 + ;; + f) fake_mode=1 + ;; + d) only_deb=1 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + show_help + exit 1 + ;; + esac +done + +shift $(($OPTIND-1)) + +release=$1 +deb_release=${release/-/\~} + +if [ -z "$release" ] +then + echo "Missing argument <release_version>" + show_help + exit 1 +fi + +if [ "$#" -gt 1 ] +then + shift + echo "Too many arguments. Don't know what to do with '$@'" + show_help + exit 1 +fi + +# Somewhat lame way to check we're in a git repo but that will do +git log -1 &> /dev/null +if [ $? -ne 0 ] +then + echo "The current directory does not appear to be a git repository." + echo "You must run this from the Cassandra git source repository." + exit 1 +fi + +head_commit=`git log --pretty=oneline -1 | cut - -d " " -f 1` + +if [ "$release" == "$deb_release" ] +then + echo "Preparing release for $release from commit:" +else + echo "Preparing release for $release (debian will use $deb_release) from commit:" +fi +echo "" +git show $head_commit + +echo "Is this what you want?" +select yn in "Yes" "No"; do + case $yn in + Yes) break;; + No) echo "Alright, come back when you've made up your mind"; exit 0;; + esac +done + +# "Saves" stdout to other descriptor since we might redirect them below +exec 3>&1 4>&2 + +if [ $verbose -eq 0 ] +then + # Not verbose, redirect all ouptut to a logfile + logfile="vote-${release}.log" + [ ! -e "$logfile" ] || rm $logfile + touch $logfile + exec > $logfile + exec 2> $logfile +fi + +execute() +{ + local cmd=$1 + + echo ">> $cmd" + [ $fake_mode -eq 1 ] || $cmd + if [ $? -ne 0 ] + then + echo "Error running $cmd" 1>&3 2>&4 + exit $? + fi +} + +current_dir=`pwd` +# This appear to be the simpler way to make this work for both linux and OSX (http://goo.gl/9RKld3) +tmp_dir=`mktemp -d 2>/dev/null || mktemp -d -t 'release'` + +if [ $only_deb -eq 0 ] +then + echo "Tagging release ..." 1>&3 2>&4 + execute "git tag $release-tentative" + execute "git push $git_asf_remote refs/tags/$release-tentative" + + echo "Cloning fresh repository ..." 1>&3 2>&4 + execute "cd $tmp_dir" + ## We clone from the original repository to make extra sure we're not screwing, even if that's definitively slower + execute "git clone $asf_git_repo/cassandra.git" + + echo "Building and uploading artifacts ..." 1>&3 2>&4 + execute "cd cassandra" + execute "git checkout $release-tentative" + execute "ant realclean" + execute "ant publish -Drelease=true" + + echo "Artifacts uploaded, please close release on repository.apache.org and indicate the staging number:" 1>&3 2>&4 +else + echo "Please indicate staging number:" 1>&3 2>&4 +fi + +read -p "staging number? " staging_number 1>&3 2>&4 + +## Debian Stuffs ## + +execute "cd $debian_package_dir" + +deb_dir=cassandra_${release}_debian +[ ! -e "$deb_dir" ] || rm -rf $deb_dir +execute "mkdir $deb_dir" +execute "cd $deb_dir" + +echo "Building debian package ..." 1>&3 2>&4 + +execute "wget $staging_repo/orgapachecassandra-$staging_number/org/apache/cassandra/apache-cassandra/$release/apache-cassandra-$release-src.tar.gz" +execute "mv apache-cassandra-$release-src.tar.gz cassandra_${deb_release}.orig.tar.gz" +execute "tar xvzf cassandra_${deb_release}.orig.tar.gz" +execute "cd apache-cassandra-${release}-src" +execute "dpkg-buildpackage -rfakeroot -us -uc" +execute "cd .." +# Debsign might ask the passphrase on stdin so don't hide what he says even if no verbose +# (I haven't tested carefully but I've also seen it fail unexpectedly with it's output redirected. +execute "debsign -k$gpg_key cassandra_${deb_release}_amd64.changes" 1>&3 2>&4 + +echo "Uploading debian package ..." 1>&3 2>&4 + +cat > /tmp/sftpbatch.txt <<EOF +cd public_html +put cassandra* +EOF + + +execute "sftp -b /tmp/sftpbatch.txt ${asf_username}@${apache_host}" + +execute "cd $current_dir" + +# Restore stdout/stderr (and close temporary descriptors) if not verbose +[ $verbose -eq 1 ] || exec 1>&3 3>&- 2>&4 4>&- + +# Cleaning up +rm -rf $tmp_dir + +## Email for vote ## + +mail_file="$mail_dir/mail_vote_$release" +[ ! -e "$mail_file" ] || rm $mail_file + +echo "[VOTE] Release Apache Cassandra $release" > $mail_file +echo "" >> $mail_file +echo "I propose the following artifacts for release as $release." >> $mail_file +echo "" >> $mail_file +echo "sha1: $head_commit" >> $mail_file +echo "Git: $asf_git_repo?p=cassandra.git;a=shortlog;h=refs/tags/$release-tentative" >> $mail_file +echo "Artifacts: $staging_repo/orgapachecassandra-$staging_number/org/apache/cassandra/apache-cassandra/$release/" >> $mail_file +echo "Staging repository: $staging_repo/orgapachecassandra-$staging_number/" >> $mail_file +echo "" >> $mail_file +echo "The Debian packages are available here: http://$apache_host/~$asf_username" >> $mail_file +echo "" >> $mail_file +echo "The vote will be open for 72 hours (longer if needed)." >> $mail_file +echo "" >> $mail_file +echo "[1]: (CHANGES.txt) " >> $mail_file +echo "[2]: (NEWS.txt) " >> $mail_file + +echo "Mail written to $mail_file. You will need to complete with short links to:" +echo " 1) CHANGES.txt: $asf_git_repo?p=cassandra.git;a=blob_plain;f=CHANGES.txt;hb=refs/tags/$release-tentative" +echo " 2) NEWS.txt: $asf_git_repo?p=cassandra.git;a=blob_plain;f=NEWS.txt;hb=refs/tags/$release-tentative" http://git-wip-us.apache.org/repos/asf/cassandra-builds/blob/ac05c715/cassandra-release/upload_bintray.sh ---------------------------------------------------------------------- diff --git a/cassandra-release/upload_bintray.sh b/cassandra-release/upload_bintray.sh new file mode 100755 index 0000000..151eb71 --- /dev/null +++ b/cassandra-release/upload_bintray.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +BINTRAY_USER="$USER" +BINTRAY_KEY="XXXXXXXX" + +#Example: +#./upload_bintray.sh ~/workspace/cassandra-dist-svn/debian + +ROOTDIR=`cd -P -- "$(dirname -- "$1")" && printf '%s\n' "$(pwd -P)/$(basename -- "$1")"` +ROOTLEN=$(( ${#ROOTDIR} + 1)) + +for i in $(find ${ROOTDIR} -type f -printf "%T@ %p\n" | sort -n -r | cut -d' ' -f 2); do + IFILE=`echo $(basename -- "$i") | cut -c 1` + if [[ $IFILE != "." ]]; + then + FDIR=`echo $i | cut -c ${ROOTLEN}-${#i}` + echo "Uploading $FDIR" + curl -X PUT -T $i -u${BINTRAY_USER}:${BINTRAY_KEY} "https://api.bintray.com/content/apache/cassandra/debian/prod${FDIR}?override=1" + sleep 1 + fi +done +
