release-egg

text/x-sh icon release-egg.sh — text/x-sh, 2 KB (2776 bytes)

File contents

#!/bin/bash

# call from the directory containing the egg folders with:
#  ./release-egg my.package 1.0 1.1

if [ $# -lt 3 ]
then
echo 'Usage: release-egg.sh egg-name current_version next_version'
exit 0
fi
 
package=${1}
version=${2}
new_version=${3}

# Get repository URL
trunk_url="$(svn info | sed -ne 's/.*URL: //p')"
svn_base=${trunk_url%${package}/*}

tag_url="${svn_base}/${package}/tags/${version}"

# Save URL
distribution_target="USERNAMEN@OUR.EGG.SERVER.COM:/PATH/TO/FOLDER/."

function update_versions() {
    echo
    echo "Updating version in setup.cfg"
    mv setup.py setup.py.old
    cat setup.py.old | sed "s/^version = .*$/version = '${1}'/" > setup.py
    rm setup.py.old

    echo
    echo "Updating any version.txt files"
    for f in $(find . -name 'version.txt') ; do
        echo "${1}" > ${f}
    done

}

echo
echo "** Processing ${package} at ${trunk_url}"
echo

# echo
# echo "-> Please revise setup.py. Version will be handled separately."
# ${EDITOR} setup.py

echo
echo "-> Committing current trunk"
svn status
svn diff
read -p "Press enter to continue"
#svn commit -m "Updating setup.py"

#test $? == 0 || exit 1



echo
echo "-> Tagging release in subversion at ${tag_url}"
svn cp "${trunk_url}" "${tag_url}" -m "Tagging ${version}" 

test $? == 0 || exit 1

echo
echo "-> Switching to tag"

current="$(pwd)"
cd /tmp

svn co "${tag_url}" "${package}"
cd "${package}"

update_versions "${version}" 

test $? == 0 || exit 1

echo
echo "-> Removing setup.cfg"
svn rm setup.cfg

echo
echo "-> About to commit changes to tag"
svn status
svn diff
svn commit -m "Updating version and removing setup.cfg for the tag"

test $? == 0 || exit 1

echo
echo "-> Cheesing it up"
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
export COPYFILE_DISABLE=true

read -p "Upload to code.codesyntax.com/static? (Y/n) " static
read -p "Upload to CodeSyntax.com? (y/N)? " codesyntax
read -p "Upload to PyPI? (y/N)? " pypi

case $static in
    n|N)
    
    ;;
    *)
	python setup.py egg_info -RDb "" sdist
	ls -l dist/
	scp dist/*.tar.gz ${distribution_target}
    ;;
esac

case $codesyntax in
    y|Y)
        python setup.py egg_info -RDb "" sdist mregister mupload -r http://www.codesyntax.com/products
    ;;
    *) 

    ;;
esac

case $pypi in
    y|Y)
        python setup.py egg_info -RDb "" sdist mregister mupload -r http://pypi.python.org/pypi
    ;;
    *)
    ;;

esac

test $? == 0 || exit 1

echo
echo "-> Switching back to trunk"


rm -rf /tmp/"${package}"

cd "${current}"
svn switch "${trunk_url}"

update_versions "${new_version}" 

test $? == 0 || exit 1

echo
echo "-> About to commit new version to trunk"
svn status
svn diff
svn commit setup.py -m "Updating version on trunk after tagging"

test $? == 0 || exit 1

echo
echo "-> All done"
cd ..