def release():
    """
    Create a new release and upload it to PyPI.
    """

    if not is_working_tree_clean():
        print('Your working tree is not clean. Refusing to create a release.')
        return

    print('Rebuilding the AUTHORS file to check for modifications...')
    authors()

    if not is_working_tree_clean():
        print('Your working tree is not clean after the AUTHORS file was '
              'rebuilt.')
        print('Please commit the changes before continuing.')
        return

    if not is_manifest_up_to_date():
        print('Manifest is not up to date.')
        print('Please update MANIFEST.in or remove spurious files.')
        return

    # Get version
    version = 'v{}'.format(local('python setup.py --version', capture=True))
    name = local('python setup.py --name', capture=True)

    # Tag
    tag_message = '{} release version {}.'.format(name, version)

    print('----------------------')
    print('Proceeding will tag the release, push the repository upstream,')
    print('and release a new version on PyPI.')
    print()
    print('Version: {}'.format(version))
    print('Tag message: {}'.format(tag_message))
    print()
    if not confirm('Continue?', default=True):
        print('Aborting.')
        return

    local('git tag -a {} -m {}'.format(pipes.quote(version),
                                       pipes.quote(tag_message)))

    # Push
    local('git push --tags origin develop')

    # Package and upload to pypi
    local('python setup.py sdist bdist_wheel upload')
Create a new release and upload it to PyPI.