-
Notifications
You must be signed in to change notification settings - Fork 5
/
tasks.py
79 lines (52 loc) · 1.91 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sys
from distutils.core import run_setup
from pathlib import Path
from invoke import task
PROJECT_PATH: Path = Path(__file__).parent.absolute()
sys.path.insert(0, str(PROJECT_PATH / '.build'))
from mkdocs_markmap.__meta__ import PROJECT_VERSION
from mkdocs_markmap_build.distribution import DistributionHandler, MastodonHandler
from mkdocs_markmap_build.info import ReleaseInfo
from mkdocs_markmap_build.release import ReleaseHandler
TARGET_TAG = f'v{PROJECT_VERSION}'
@task
def verify(c, tag=TARGET_TAG):
print(f'verify integrity: {tag}')
handler: ReleaseHandler = ReleaseHandler(tag)
handler.verify()
@task
def build(c):
run_setup('setup.py', script_args=['sdist', 'bdist_wheel'])
@task
def delete_release(c, tag=TARGET_TAG, yes=False):
print(f'delete tag and release: {tag}')
if not yes and input('Are you sure [y/N]? ').lower() != 'y':
print('aborted by user')
sys.exit(1)
handler: ReleaseHandler = ReleaseHandler(tag)
handler.delete()
@task
def release(c, commit=None, tag=TARGET_TAG, dry_run=True):
print(f'create tag and release: {tag}')
handler: ReleaseHandler = ReleaseHandler(tag)
handler.create(commit, dry_run=dry_run)
@task
def info(c, tag=None, github=False, pypi=False):
if tag is None:
print('show latest release info')
else:
print(f'show release info: {tag}')
print_github = github or not (github or pypi)
print_pypi = pypi or not (github or pypi)
release: ReleaseInfo = ReleaseInfo(tag)
release.print(github=print_github, pypi=print_pypi)
@task
def mastodon(c, tag=TARGET_TAG):
print(f'post status: {tag}')
handler: MastodonHandler = MastodonHandler(tag)
handler.post()
@task(post=[mastodon])
def distribute(c, tag=TARGET_TAG, dry_run=True):
print(f'distribute release: {tag}')
handler: DistributionHandler = DistributionHandler(tag)
handler.distribute(dry_run=dry_run)