1
|
|
|
import logging |
2
|
|
|
|
3
|
|
|
import click |
|
|
|
|
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 |
|
|
|
|
8
|
|
|
from changes.vcs import tag_and_push, commit_version_change, create_github_release, upload_release_distributions |
|
|
|
|
9
|
|
|
from changes.verification import run_tests |
10
|
|
|
from changes.version import increment_version |
11
|
|
|
|
12
|
|
|
log = logging.getLogger(__name__) |
|
|
|
|
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) |
|
|
|
|
22
|
|
|
if not project_settings['gh_token']: |
23
|
|
|
click.echo('You need a GitHub token for changes to create a release.') |
|
|
|
|
24
|
|
|
click.pause('Press [enter] to launch the GitHub "New personal access ' |
|
|
|
|
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') |
|
|
|
|
28
|
|
|
|
29
|
|
|
store_settings(context.module_name, project_settings) |
|
|
|
|
30
|
|
|
description = click.prompt('Describe this release') |
31
|
|
|
|
32
|
|
|
upload_url = create_github_release(context, project_settings['gh_token'], description) |
|
|
|
|
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)) |
|
|
|
|
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
|
|
|
|
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.
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.