Skip to content

Commit

Permalink
Merge pull request #6 from XueyanZhang/master
Browse files Browse the repository at this point in the history
update release.py
  • Loading branch information
chengniansun committed Oct 4, 2020
2 parents 88e7287 + 7a00016 commit 1efeefd
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/usr/bin/env python3

import os
import re
import subprocess


def create_tag():
subprocess.check_call(["git", "fetch", "--all", "--tags"]) # fetch remote tags
subprocess.check_call(["git", "fetch", "--all", "--tags"])
# create new tag as per current release
stream = os.popen('git describe --abbrev=0 --tags')
current_tag = stream.read().strip()
# TODO(Xueyan): the current parsing is buggy, if the main version number is a two-digit number.
# You need parse the string, e.g., the first string is 'v', and after 'v', there should be
# two numbers seperated by a '.'
if current_tag[0] != 'v':
raise Exception("The tag name should start with v")
major_version = int(current_tag[1])
minor_version = int(current_tag[3])
q, r = divmod(minor_version + 1, 10)
return "v{}.{}".format(major_version + q, r)

if not re.match("^v[0-9]+[.][0-9]", current_tag):
raise Exception("Error: tag name does not follow expected pattern.")

version = current_tag[1:].split('.')

major_version = int(version[0])
minor_version = int(version[1])
increment, new_minor_version = divmod(minor_version + 1, 10)

return f"v{major_version + increment}.{new_minor_version}"


def build_binary():
Expand All @@ -40,13 +43,13 @@ def main():
raise Exception('ERROR: This script should be run in the root folder of the project.')

tag_name = create_tag()
title = "Perses {}".format(tag_name)
title = f"Perses {tag_name}"

# get built binary path
jar = build_binary()

# release
release_command = ['hub', 'release', 'create', '-a', jar, '-m', title, tag_name]
release_command = ['hub', 'release', 'create', '--browse', f"--attach={jar}", f'--message={title}', tag_name]

pipe = None
subprocess.check_call(
Expand Down

0 comments on commit 1efeefd

Please sign in to comment.