=======
release
=======

The release module provides a script to release an egg.

The steps are:

- running tests
- raising the version in setup.py
- building the changes
- creating a branch vor this version
- creating a tag
- uploading over cheeseshop
- sending a mail that list the changes

Let's set the curdir to the package we work on, because releaser uses
the current working directory to work::

    >>> import os
    >>> package_dir = os.path.join(test_dir, 'data', 'my.package')
    >>> os.chdir(package_dir)

Let's get the version::

    >>> import release
    >>> release.get_version()
    '0.1'

Now we are going to create a release, let's save at first the package::

    >>> import shutil
    >>> shutil.copytree(package_dir, package_dir + '_backup')


First step, let's check the tests passes::

    >>> release.check_tests()
    True

If a test fails, this will return False::
    
    >>> failure = '    >>> 1 + 1\n    3\n'
    >>> failfile = os.path.join(package_dir, 'my', 'package',
    ...                         'doctests', 'fail.txt')
    >>> f = open(failfile, 'w')
    >>> f.write(failure)
    >>> f.close()
    >>> release.check_tests()
    False
    >>> os.remove(failfile)

Now that we are sure all tests passes, let's raise the version::

    >>> release.raise_version('0.2')
    >>> release.get_version()  
    '0.2'

Let's build CHANGES::

    >>> CHANGES = os.path.join(package_dir, 'CHANGES') 
    >>> print open(CHANGES).read()
    * trunk
     - added the cool feature
    <BLANKLINE>
    * '0.1'
     - initial version created by IngeniSkel
    <BLANKLINE>
    <BLANKLINE>
 
    >>> release.increment_changes()
    >>> print open(CHANGES).read()
    * trunk
      -
    * 0.2
     - added the cool feature
    <BLANKLINE>
    * '0.1'
     - initial version created by IngeniSkel
    <BLANKLINE>
    <BLANKLINE>

Now let's commiting the changes over subversion::

    >>> release.create_branches()

This creates a branch and a tag for the version.

Now we can upload on cheeseshop if needed::

    >>> release.pypi_upload()

Let's clean the folder::

    >>> shutil.rmtree(package_dir)
    >>> shutil.copytree(package_dir + '_backup', package_dir)
    >>> shutil.rmtree(package_dir + '_backup')

    
