2022-03-30 07:42:07 +02:00
|
|
|
import code
|
2021-02-07 13:52:03 +01:00
|
|
|
import subprocess
|
|
|
|
import click
|
|
|
|
import re
|
|
|
|
|
|
|
|
@click.group()
|
|
|
|
def main():
|
|
|
|
pass
|
|
|
|
|
|
|
|
@click.command()
|
|
|
|
@click.option('-m', prompt='Commit Message')
|
|
|
|
def commit(m):
|
2022-03-30 07:42:07 +02:00
|
|
|
|
|
|
|
new_content = []
|
2021-02-07 13:52:03 +01:00
|
|
|
file = "./cbpi/__init__.py"
|
|
|
|
with open(file) as reader:
|
|
|
|
match = re.search('.*\"(.*)\"', reader.readline())
|
2022-03-30 07:42:07 +02:00
|
|
|
codename = reader.readline()
|
|
|
|
try:
|
|
|
|
major, minor, patch, build = match.group(1).split(".")
|
|
|
|
except:
|
|
|
|
major, minor, patch = match.group(1).split(".")
|
|
|
|
patch = int(patch)
|
|
|
|
patch += 1
|
|
|
|
new_content.append("__version__ = \"{}.{}.{}\"".format(major,minor,patch))
|
|
|
|
new_content.append(codename)
|
2021-02-07 13:52:03 +01:00
|
|
|
with open(file,'w',encoding = 'utf-8') as file:
|
2022-03-30 07:42:07 +02:00
|
|
|
print("New Version {}.{}.{}".format(major,minor,patch))
|
|
|
|
file.writelines("%s\n" % i for i in new_content)
|
2021-02-07 13:52:03 +01:00
|
|
|
|
|
|
|
subprocess.run(["git", "add", "-A"])
|
|
|
|
subprocess.run(["git", "commit", "-m", "\"{}\"".format(m)])
|
|
|
|
subprocess.run(["git", "push"])
|
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
|
|
|
def build():
|
|
|
|
subprocess.run(["python3", "setup.py", "sdist"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command()
|
|
|
|
def release():
|
|
|
|
subprocess.run(["python3", "setup.py", "sdist"])
|
|
|
|
file = "./cbpi/__init__.py"
|
|
|
|
with open(file) as reader:
|
|
|
|
match = re.search('.*\"(.*)\"', reader.readline())
|
|
|
|
version = match.group(1)
|
|
|
|
|
2022-05-12 21:27:12 +02:00
|
|
|
path = "dist/cbpi4-{}.tar.gz".format(version)
|
2021-02-07 13:52:03 +01:00
|
|
|
print("Uploading File {} ".format(path))
|
|
|
|
subprocess.run(["twine", "upload", path])
|
|
|
|
|
|
|
|
|
|
|
|
main.add_command(commit)
|
|
|
|
main.add_command(release)
|
|
|
|
main.add_command(build)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|