Completed
Push — init-test ( 3e12e7 )
by Michael
07:46 queued 07:14
created

publish()   B

Complexity

Conditions 3

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
dl 0
loc 30
ccs 0
cts 16
cp 0
crap 12
rs 8.8571
1
import logging
2
3
import click
0 ignored issues
show
Configuration introduced by
The import click could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
4
5
from changes.changelog import generate_changelog
6
from changes.config import project_config, store_settings
7
from changes.packaging import build_distributions, install_package, upload_package, install_from_pypi
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
8
from changes.vcs import tag_and_push, commit_version_change, create_github_release, upload_release_distributions
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (112/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
9
from changes.verification import run_tests
10
from changes.version import increment_version
11
12
log = logging.getLogger(__name__)
0 ignored issues
show
Coding Style Naming introduced by
The name log does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
13
14
15
def publish(context):
16
    """Publishes the project"""
17
    commit_version_change(context)
18
19
    if context.github:
20
        # github token
21
        project_settings = project_config(context.module_name)
0 ignored issues
show
Bug introduced by
There seem to be too many positional arguments for this function call.
Loading history...
22
        if not project_settings['gh_token']:
23
            click.echo('You need a GitHub token for changes to create a release.')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
24
            click.pause('Press [enter] to launch the GitHub "New personal access '
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
25
                        'token" page, to create a token for changes.')
26
            click.launch('https://github.com/settings/tokens/new')
27
            project_settings['gh_token'] = click.prompt('Enter your changes token')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
28
29
            store_settings(context.module_name, project_settings)
0 ignored issues
show
Bug introduced by
There seem to be too many positional arguments for this function call.
Loading history...
30
        description = click.prompt('Describe this release')
31
32
        upload_url = create_github_release(context, project_settings['gh_token'], description)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (94/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
33
34
        upload_release_distributions(
35
            context,
36
            project_settings['gh_token'],
37
            build_distributions(context),
38
            upload_url,
39
        )
40
41
        click.pause('Press [enter] to review and update your new release')
42
        click.launch('{0}/releases/tag/{1}'.format(context.repo_url, context.new_version))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (90/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
43
    else:
44
        tag_and_push(context)
45
46
47
def perform_release(context):
48
    """Executes the release process."""
49
    try:
50
        run_tests()
51
52
        if not context.skip_changelog:
53
            generate_changelog(context)
54
55
        increment_version(context)
56
57
        build_distributions(context)
58
59
        install_package(context)
60
61
        upload_package(context)
62
63
        install_from_pypi(context)
64
65
        publish(context)
66
    except:
67
        log.exception('Error releasing')
68