-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
executable file
·42 lines (29 loc) · 990 Bytes
/
release.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
#!/usr/bin/env python
import os
import sys
import subprocess
import shutil
from setuptools.sandbox import run_setup
from git import Repo
project_root = os.path.dirname(os.path.abspath(__file__))
version_path = os.path.join(project_root, '.VERSION')
setup_path = os.path.join(project_root, 'setup.py')
dist_path = os.path.join(project_root, 'dist')
os.chdir(project_root)
print(f'Changed working directory to project root: {project_root}')
with open(version_path) as f:
version = f.read().strip()
repo = Repo(project_root)
if version in repo.tags:
print(f'Tag {version} already used')
sys.exit(1)
repo.create_tag(version)
print(f'Tag {version} created')
repo.remotes.origin.push(version)
print(f'Tag {version} pushed')
shutil.rmtree(dist_path)
print('Deleted dist dir')
run_setup(setup_path, ['sdist', 'bdist_wheel'])
print(f'Artifacts for {version} created')
subprocess.check_call(['python', '-m', 'twine', 'upload', 'dist/*'])
print(f'Uploaded {version} to pypi')