Ejemplo n.º 1
0
def release(ver, dry_run):
    """Tags all submodules for a new release.

    Ensures that git tags, as well as the version.py files in each submodule, agree and that the
    new version is strictly greater than the current version. Will fail if the new version
    is not an increment (following PEP 440). Creates a new git tag and commit.
    """
    dmp = DagsterModulePublisher()
    dmp.check_new_version(ver)
    dmp.set_version_info(new_version=ver, dry_run=dry_run)
    dmp.commit_new_version(ver, dry_run=dry_run)
    set_git_tag(ver, dry_run=dry_run)
    click.echo(
        "Successfully set new version and created git tag {version}. You may continue with the "
        "release checklist.".format(version=ver))
Ejemplo n.º 2
0
def publish(nightly, autoclean, dry_run):
    '''Publishes (uploads) all submodules to PyPI.

    Appropriate credentials must be available to twine, e.g. in a ~/.pypirc file, and users must
    be permissioned as maintainers on the PyPI projects. Publishing will fail if versions (git
    tags and Python versions) are not in lockstep, if the current commit is not tagged, or if
    there are untracked changes.
    '''
    assert os.getenv('SLACK_RELEASE_BOT_TOKEN'
                     ), 'No SLACK_RELEASE_BOT_TOKEN env variable found.'

    try:
        RCParser.from_file()
    except ConfigFileError:
        raise ConfigFileError(PYPIRC_EXCEPTION_MESSAGE)

    assert '\nwheel' in subprocess.check_output([
        'pip', 'list'
    ]).decode('utf-8'), (
        'You must have wheel installed in order to build packages for release -- run '
        '`pip install wheel`.')

    assert which_('twine'), (
        'You must have twine installed in order to upload packages to PyPI -- run '
        '`pip install twine`.')

    assert which_('yarn'), (
        'You must have yarn installed in order to build dagit for release -- see '
        'https://yarnpkg.com/lang/en/docs/install/')
    dmp = DagsterModulePublisher()

    checked_version = dmp.check_versions(nightly=nightly)
    if not nightly:
        click.echo('... and match git tag on most recent commit...')
        git_check_status()
    click.echo('... and that there is no cruft present...')
    dmp.check_for_cruft(autoclean)
    click.echo('... and that the directories look like we expect')
    dmp.check_directory_structure()

    click.echo('Publishing packages to PyPI...')

    if nightly:
        new_nightly_version = dmp.set_version_info(
            dry_run=dry_run)['__nightly__']
        dmp.commit_new_version(
            'nightly: {nightly}'.format(nightly=new_nightly_version),
            dry_run=dry_run)
        tag = set_git_tag('nightly-{ver}'.format(ver=new_nightly_version),
                          dry_run=dry_run)
        git_push(dry_run=dry_run)
        git_push(tag, dry_run=dry_run)

    dmp.publish_all(nightly, dry_run=dry_run)

    if not nightly:
        parsed_version = packaging.version.parse(
            checked_version['__version__'])
        if not parsed_version.is_prerelease and not dry_run:
            slack_client = slackclient.SlackClient(
                os.environ['SLACK_RELEASE_BOT_TOKEN'])
            slack_client.api_call(
                'chat.postMessage',
                channel='#general',
                text=('{git_user} just published a new version: {version}.'
                      ).format(git_user=git_user(),
                               version=checked_version['__version__']),
            )