Skip to content

Commit

Permalink
Update version to use alpha instead of dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tandemdude committed May 1, 2024
1 parent 4dd78ff commit 3fe430c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- major
- minor
- patch
- dev
- alpha
increment:
description: "Whether to increment the version before release."
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion lightbulb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
]

# Do not change the below field manually. It is updated by CI upon release.
__version__ = "3.0.0.dev0"
__version__ = "3.0.0a0"
16 changes: 8 additions & 8 deletions scripts/deploy/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import re
import sys

VERSION_REGEX = re.compile(r"__version__\s*=\s*\"(?P<version>\d+\.\d+\.\d+)(?:\.dev(?P<devnum>\d+))?\"")
VERSION_REGEX = re.compile(r"__version__\s*=\s*\"(?P<version>\d+\.\d+\.\d+)(?:a(?P<alphanum>\d+))?\"")

parser = argparse.ArgumentParser()
parser.add_argument("type", choices=["major", "minor", "patch", "dev"])
parser.add_argument("type", choices=["major", "minor", "patch", "alpha"])
parser.add_argument("increment")

_noop = lambda n: n # noqa: E731
Expand All @@ -36,7 +36,7 @@
"major": (_increment, _reset, _reset, _reset),
"minor": (_noop, _increment, _reset, _reset),
"patch": (_noop, _noop, _increment, _reset),
"dev": (_noop, _noop, _noop, _increment),
"alpha": (_noop, _noop, _noop, _increment),
}


Expand All @@ -49,21 +49,21 @@ def run(version_type: str, increment: str) -> None:
raise RuntimeError("Could not find version in __init__ file")

version = current_version.groupdict()["version"]
dev = current_version.groupdict().get("devnum", "0")
alpha = current_version.groupdict().get("alphanum", "0")

if increment.lower() != "true":
sys.stdout.write(f"{version}{('.dev' + dev) if version_type.lower() == 'dev' else ''}")
sys.stdout.write(f"{version}{('a' + alpha) if version_type.lower() == 'alpha' else ''}")
return

major, minor, patch = version.split(".")

actions = ACTIONS[version_type.lower()]
major, minor, patch, dev = [a(s) for a, s in zip(actions, [major, minor, patch, dev])]
major, minor, patch, alpha = [a(s) for a, s in zip(actions, [major, minor, patch, alpha])]

new_version = f"{major}.{minor}.{patch}"

if version_type.lower() == "dev":
new_version += f".dev{dev}"
if version_type.lower() == "alpha":
new_version += f"a{alpha}"

updated_file_content = VERSION_REGEX.sub(f'__version__ = "{new_version}"', content)
with open("lightbulb/__init__.py", "w") as fp:
Expand Down

0 comments on commit 3fe430c

Please sign in to comment.