Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.4 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python
# Modify version...
import datetime
import os
import re
import subprocess
import sys
def main(argv):
2022-05-30 22:38:49 +01:00
DEV_RELEASE = os.environ.get("DEV_RELEASE", None) == "1"
PROJECT_DIRECTORY = os.getcwd()
PROJECT_DIRECTORY_NAME = os.path.basename(os.path.abspath(PROJECT_DIRECTORY))
PROJECT_NAME = PROJECT_DIRECTORY_NAME.replace("_", "-")
2022-06-10 16:05:22 +01:00
version = argv[1]
setup_cfg_path = os.path.join(PROJECT_DIRECTORY, "setup.cfg")
2019-05-28 15:12:12 -04:00
if not DEV_RELEASE:
history_path = os.path.join(PROJECT_DIRECTORY, "HISTORY.rst")
2022-05-30 22:38:49 +01:00
with open(history_path) as f:
history = f.read()
2019-05-28 15:12:12 -04:00
today = datetime.datetime.today()
2022-02-03 12:40:03 +00:00
today_str = today.strftime("%Y-%m-%d")
2022-03-08 13:09:10 +00:00
history = history.replace(".dev0", f" ({today_str})")
2022-05-30 22:38:49 +01:00
with open(history_path, "w") as f:
f.write(history)
2022-06-10 16:05:22 +01:00
with open(setup_cfg_path) as f:
setup_cfg = f.read()
setup_cfg = re.sub(
r"^version = [\d\.]+\.dev\d+", f"version = {version}", setup_cfg, count=1, flags=re.MULTILINE
)
with open(setup_cfg_path, "w") as f:
f.write(setup_cfg)
2020-10-06 18:49:19 +01:00
tag = f"galaxy-{PROJECT_NAME}-{version}"
2022-06-10 16:05:22 +01:00
shell(["git", "commit", "-m", f"Version {version} of {PROJECT_NAME} (tag {tag}).", "HISTORY.rst", setup_cfg_path])
shell(["git", "tag", tag])
def shell(cmds, **kwds):
p = subprocess.Popen(cmds, **kwds)
return p.wait()
if __name__ == "__main__":
main(sys.argv)