Skip to content

Commit

Permalink
git: use semver
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Jul 20, 2023
1 parent d7d3362 commit 37c0f4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
black==22.3.0
faasmctl==0.5.6
faasmctl==0.7.1
flake8==3.9.2
invoke>=2.0.0
numpy==1.22.0
Expand Down
32 changes: 22 additions & 10 deletions tasks/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,32 @@ def get_tag_name(version):


@task
def bump(ctx, ver=None):
def bump(ctx, patch=False, minor=False, major=False):
"""
Bump code version
Bump the code version by --patch, --minor, or --major
"""
old_ver = get_version()

if ver:
new_ver = ver
new_ver_parts = old_ver.split(".")

if patch:
idx = 2
elif minor:
idx = 1
elif major:
idx = 0
else:
# Just bump the last minor version part
new_ver_parts = old_ver.split(".")
new_ver_minor = int(new_ver_parts[-1]) + 1
new_ver_parts[-1] = str(new_ver_minor)
new_ver = ".".join(new_ver_parts)
raise RuntimeError("Must set one in: --[patch,minor,major]")

# Change the corresponding idx
new_ver_parts[idx] = str(int(new_ver_parts[idx]) + 1)

# Zero-out the following version numbers (i.e. lower priority). This is
# because if we tag a new major release, we want to zero-out the minor
# and patch versions (e.g. 0.2.0 comes after 0.1.9)
for next_idx in range(idx + 1, 3):
new_ver_parts[next_idx] = "0"

new_ver = ".".join(new_ver_parts)

# Replace version in all files
for f in VERSIONED_FILES:
Expand Down

0 comments on commit 37c0f4b

Please sign in to comment.