1
|
3 |
|
import io |
2
|
3 |
|
import logging |
3
|
|
|
|
4
|
3 |
|
import click |
|
|
|
|
5
|
|
|
|
6
|
3 |
|
import requests |
7
|
3 |
|
from uritemplate import expand |
|
|
|
|
8
|
|
|
|
9
|
3 |
|
from changes import shell, probe |
10
|
|
|
|
11
|
3 |
|
log = logging.getLogger(__name__) |
|
|
|
|
12
|
|
|
|
13
|
3 |
|
COMMIT_TEMPLATE = 'git commit --message="%s" %s/__init__.py CHANGELOG.md' |
14
|
3 |
|
TAG_TEMPLATE = 'git tag %s %s --message="%s"' |
15
|
|
|
|
16
|
3 |
|
EXT_TO_MIME_TYPE = { |
17
|
|
|
'.gz': 'application/x-gzip', |
18
|
|
|
'.whl': 'application/zip', |
19
|
|
|
'.zip': 'application/zip', |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
|
23
|
3 |
|
def commit_version_change(context): |
24
|
|
|
# TODO: signed commits? |
25
|
3 |
|
shell.dry_run(COMMIT_TEMPLATE % (context.new_version, context.module_name), context.dry_run) |
|
|
|
|
26
|
3 |
|
shell.dry_run('git push', context.dry_run) |
27
|
|
|
|
28
|
|
|
|
29
|
3 |
|
def tag_and_push(context): |
30
|
|
|
"""Tags your git repo with the new version number""" |
31
|
3 |
|
tag_option = '--annotate' |
32
|
3 |
|
if probe.has_signing_key(context): |
33
|
|
|
tag_option = '--sign' |
34
|
|
|
|
35
|
3 |
|
shell.dry_run(TAG_TEMPLATE % (tag_option, context.new_version, context.new_version), context.dry_run) |
|
|
|
|
36
|
|
|
|
37
|
3 |
|
shell.dry_run('git push --tags', context.dry_run) |
38
|
|
|
|
39
|
|
|
|
40
|
3 |
|
def create_github_release(context, gh_token, description): |
41
|
|
|
|
42
|
|
|
params = { |
43
|
|
|
'tag_name': context.new_version, |
44
|
|
|
'name': description, |
45
|
|
|
'body': ''.join(context.changelog_content), |
46
|
|
|
'prerelease': True, |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
response = requests.post( |
50
|
|
|
'https://api.github.com/repos/{owner}/{repo}/releases'.format( |
51
|
|
|
owner=context.owner, |
52
|
|
|
repo=context.repo, |
53
|
|
|
), |
54
|
|
|
auth=(gh_token, 'x-oauth-basic'), |
55
|
|
|
json=params, |
56
|
|
|
).json() |
57
|
|
|
|
58
|
|
|
click.echo('Created release {response}'.format(response=response)) |
59
|
|
|
return response['upload_url'] |
60
|
|
|
|
61
|
|
|
|
62
|
3 |
|
def upload_release_distributions(context, gh_token, distributions, upload_url): |
63
|
|
|
for distribution in distributions: |
64
|
|
|
click.echo('Uploading {distribution} to {upload_url}'.format( |
65
|
|
|
distribution=distribution, |
66
|
|
|
upload_url=upload_url |
67
|
|
|
)) |
68
|
|
|
response = requests.post( |
69
|
|
|
expand(upload_url, dict(name=distribution.name)), |
70
|
|
|
auth=(gh_token, 'x-oauth-basic'), |
71
|
|
|
headers={ |
72
|
|
|
'content-type': EXT_TO_MIME_TYPE[distribution.ext] |
73
|
|
|
}, |
74
|
|
|
data=io.open(distribution, mode='rb'), |
75
|
|
|
verify=False, |
76
|
|
|
) |
77
|
|
|
click.echo('Upload response: {response}'.format(response=response)) |
78
|
|
|
|
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.