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, |
26
|
|
|
context.module_name), context.dry_run) |
27
|
3 |
|
shell.dry_run('git push', context.dry_run) |
28
|
|
|
|
29
|
|
|
|
30
|
3 |
|
def tag_and_push(context): |
31
|
|
|
"""Tags your git repo with the new version number""" |
32
|
3 |
|
tag_option = '--annotate' |
33
|
3 |
|
if probe.has_signing_key(context): |
34
|
|
|
tag_option = '--sign' |
35
|
|
|
|
36
|
3 |
|
shell.dry_run(TAG_TEMPLATE % (tag_option, context.new_version, |
37
|
|
|
context.new_version), context.dry_run) |
38
|
|
|
|
39
|
3 |
|
shell.dry_run('git push --tags', context.dry_run) |
40
|
|
|
|
41
|
|
|
|
42
|
3 |
|
def create_github_release(context, gh_token, description): |
43
|
|
|
|
44
|
|
|
params = { |
45
|
|
|
'tag_name': context.new_version, |
46
|
|
|
'name': description, |
47
|
|
|
'body': ''.join(context.changelog_content), |
48
|
|
|
'prerelease': True, |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
response = requests.post( |
52
|
|
|
'https://api.github.com/repos/{owner}/{repo}/releases'.format( |
53
|
|
|
owner=context.owner, |
54
|
|
|
repo=context.repo, |
55
|
|
|
), |
56
|
|
|
auth=(gh_token, 'x-oauth-basic'), |
57
|
|
|
json=params, |
58
|
|
|
).json() |
59
|
|
|
|
60
|
|
|
click.echo('Created release {response}'.format(response=response)) |
61
|
|
|
return response['upload_url'] |
62
|
|
|
|
63
|
|
|
|
64
|
3 |
|
def upload_release_distributions(context, gh_token, distributions, upload_url): |
65
|
|
|
for distribution in distributions: |
66
|
|
|
click.echo('Uploading {distribution} to {upload_url}'.format( |
67
|
|
|
distribution=distribution, |
68
|
|
|
upload_url=upload_url |
69
|
|
|
)) |
70
|
|
|
response = requests.post( |
71
|
|
|
expand(upload_url, dict(name=distribution.name)), |
72
|
|
|
auth=(gh_token, 'x-oauth-basic'), |
73
|
|
|
headers={ |
74
|
|
|
'content-type': EXT_TO_MIME_TYPE[distribution.ext] |
75
|
|
|
}, |
76
|
|
|
data=io.open(distribution, mode='rb'), |
77
|
|
|
verify=False, |
78
|
|
|
) |
79
|
|
|
click.echo('Upload response: {response}'.format(response=response)) |
80
|
|
|
|
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.