Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jsnjack/hugo-changelog-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYauhen Shulitski <jsnjack@gmail.com>2018-11-23 18:49:10 +0300
committerYauhen Shulitski <jsnjack@gmail.com>2018-11-23 18:49:10 +0300
commitca46c24b1f4e1bb66b56894d1b3f6a367c48f248 (patch)
treecf7fe30396135e47c54a05a69f7acfa185d0c336
parente1cb872bc0f994acc2718c04d8e34de9411d831f (diff)
Update release script
-rw-r--r--release.py52
1 files changed, 37 insertions, 15 deletions
diff --git a/release.py b/release.py
index edd7090..ea00806 100644
--- a/release.py
+++ b/release.py
@@ -37,8 +37,8 @@ def main():
else:
print("Unexpected file: %s" % item)
if changes:
- version = release(changes)
- commit_release(version)
+ human_version = release(changes)
+ commit_release(human_version)
else:
print("No changes")
@@ -57,24 +57,27 @@ def process_change(path):
def release(changes):
"""
- Release version - move from experimental/ to released/
+ Release version - move from experimental/ to released/.
+ Returns human version - the one suitable for tagging and displaying in changelog
"""
print("Releasing changes...")
- version = get_current_version() + 1
- print("Assigning version %s" % version)
+ current_internal_version = get_current_internal_version()
+ human_version = increase_human_version(current_internal_version)
data = frontmatter.loads(changes)
- data["weight"] = version
- data["title"] = datetime.datetime.now().strftime("%Y-%m-%d")
+ data["weight"] = current_internal_version + 1
+ data["subtitle"] = datetime.datetime.now().strftime("released on %Y-%m-%d")
data["draft"] = False
data["date"] = datetime.datetime.now() # 2018-10-02T09:29:50Z
+ data["version"] = human_version
+ print("Assigning new version: %s / %s" % (data["weight"], data["version"]))
released_file_path = os.path.join(RELEASED_DIR, "%s.md" % data["weight"])
with open(released_file_path, "wb") as released_file:
frontmatter.dump(data, released_file)
print("Created: %s" % released_file_path)
- return version
+ return human_version
-def commit_release(version):
+def commit_release(human_version):
"""
Autogenerates commit and tag
"""
@@ -82,13 +85,13 @@ def commit_release(version):
subprocess.call(["git", "add", CONTENT_DIR])
subprocess.call(["git", "commit", "-m", "Generated by release script"])
subprocess.call(["git", "fetch", "--tags"])
- subprocess.call(["git", "tag", "-d", "v%s" % version])
- subprocess.call(["git", "tag", "v%s" % version])
+ subprocess.call(["git", "tag", "-d", "%s" % human_version])
+ subprocess.call(["git", "tag", "%s" % human_version])
-def get_current_version():
+def get_current_internal_version():
"""
- Get current version from files in released/ folder
+ Get current version from files in released/ folder (weight/filename)
"""
version = 0
files = os.listdir(RELEASED_DIR)
@@ -100,13 +103,32 @@ def get_current_version():
return version
+def increase_human_version(internal_version):
+ """
+ Increase human version from previous file
+ """
+ current_human_version = get_current_human_version(internal_version)
+ ma, mi = current_human_version.split(".")
+ return "%s.%s" % (ma, int(mi) + 1)
+
+
+def get_current_human_version(internal_version):
+ """
+ Returns version from frontmatter (used for tagging and displaying)
+ """
+ md_path = os.path.join(RELEASED_DIR, "%s.md" % internal_version)
+ with open(md_path, "rb") as md_file:
+ data = frontmatter.load(md_file)
+ return data["version"].strip()
+
+
def print_release_version():
"""
Returns release version
"""
- version = get_current_version()
+ version = get_current_human_version(get_current_internal_version())
is_experimental = len([x for x in os.listdir(EXPERIMENTAL_DIR) if x.endswith(".md")]) > 0
- print("v%s%s" % (version, "+" if is_experimental else ""))
+ print("%s%s" % (version, "+" if is_experimental else ""))
def natural_sort(el):