diff --git a/.github/workflows/bump_version_pr.yaml b/.github/workflows/bump_version_pr.yaml index e67e2448..cbcbb39a 100644 --- a/.github/workflows/bump_version_pr.yaml +++ b/.github/workflows/bump_version_pr.yaml @@ -14,7 +14,7 @@ on: - major - minor - patch - - dev + - rc jobs: publish: diff --git a/pyproject.toml b/pyproject.toml index 2ed00cb9..9bf04532 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ where = ["src"] # https://pypi.org/project/bumpver [tool.bumpver] current_version = "0.1.16" -version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]" +version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]" commit_message = "Bump version {old_version} -> {new_version}" commit = true tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml diff --git a/src/allencell_ml_segmenter/_tests/scripts/pyproject.toml b/src/allencell_ml_segmenter/_tests/scripts/pyproject.toml index 1b6ab2a5..cef428db 100644 --- a/src/allencell_ml_segmenter/_tests/scripts/pyproject.toml +++ b/src/allencell_ml_segmenter/_tests/scripts/pyproject.toml @@ -5,7 +5,7 @@ version = "0.0.1" # https://pypi.org/project/bumpver [tool.bumpver] current_version = "0.0.1" -version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]" +version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]" commit = false tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml push = false diff --git a/src/allencell_ml_segmenter/_tests/scripts/test_bumpver_handler.py b/src/allencell_ml_segmenter/_tests/scripts/test_bumpver_handler.py index 853963b0..0011622a 100644 --- a/src/allencell_ml_segmenter/_tests/scripts/test_bumpver_handler.py +++ b/src/allencell_ml_segmenter/_tests/scripts/test_bumpver_handler.py @@ -103,20 +103,20 @@ def test_bump_major() -> None: navigate_back_to_root_dir() -def test_bump_dev() -> None: +def test_bump_rc() -> None: navigate_to_test_dir_and_reset_version() # ASSERT (sanity check) assert_curr_version_number(DEFAULT_START_VERSION) - # ACT (create new patch version with .dev0 tag) - sys.argv = ["bumpver_handler.py", "dev"] + # ACT (create new patch version with .rc0 tag) + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() # ASSERT - assert_curr_version_number("0.0.2.dev0") + assert_curr_version_number("0.0.2rc0") # ACT - sys.argv = ["bumpver_handler.py", "dev"] + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() # ASSERT - assert_curr_version_number("0.0.2.dev1") + assert_curr_version_number("0.0.2rc1") # ACT (finalize the new patch version) sys.argv = ["bumpver_handler.py", "patch"] bumpver_handler.main() @@ -133,24 +133,24 @@ def test_bump_post() -> None: sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT - assert_curr_version_number("0.0.1.post0") + assert_curr_version_number("0.0.1post0") # ACT sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT - assert_curr_version_number("0.0.1.post1") + assert_curr_version_number("0.0.1post1") navigate_back_to_root_dir() -def test_bump_minor_fails_when_dev_current() -> None: +def test_bump_minor_fails_when_rc_current() -> None: navigate_to_test_dir_and_reset_version() # ASSERT (sanity check) assert_curr_version_number(DEFAULT_START_VERSION) - # ACT (create new dev version with .dev0 tag) - sys.argv = ["bumpver_handler.py", "dev"] + # ACT (create new rc version with .rc0 tag) + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.2.dev0") + assert_curr_version_number("0.0.2rc0") got_expected_exception: bool = False try: @@ -166,15 +166,15 @@ def test_bump_minor_fails_when_dev_current() -> None: navigate_back_to_root_dir() -def test_bump_major_fails_when_dev_current() -> None: +def test_bump_major_fails_when_rc_current() -> None: navigate_to_test_dir_and_reset_version() # ASSERT (sanity check) assert_curr_version_number(DEFAULT_START_VERSION) - # ACT (create new dev version with .dev0 tag) - sys.argv = ["bumpver_handler.py", "dev"] + # ACT (create new rc version with .rc0 tag) + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.2.dev0") + assert_curr_version_number("0.0.2rc0") got_expected_exception: bool = False try: @@ -190,15 +190,15 @@ def test_bump_major_fails_when_dev_current() -> None: navigate_back_to_root_dir() -def test_bump_post_fails_when_dev_current() -> None: +def test_bump_post_fails_when_rc_current() -> None: navigate_to_test_dir_and_reset_version() # ASSERT (sanity check) assert_curr_version_number(DEFAULT_START_VERSION) - # ACT (create new dev version with .dev0 tag) - sys.argv = ["bumpver_handler.py", "dev"] + # ACT (create new rc version with .rc0 tag) + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.2.dev0") + assert_curr_version_number("0.0.2rc0") got_expected_exception: bool = False try: @@ -222,7 +222,7 @@ def test_bump_minor_fails_when_post_current() -> None: sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.1.post0") + assert_curr_version_number("0.0.1post0") got_expected_exception: bool = False try: @@ -246,7 +246,7 @@ def test_bump_major_fails_when_post_current() -> None: sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.1.post0") + assert_curr_version_number("0.0.1post0") got_expected_exception: bool = False try: @@ -270,7 +270,7 @@ def test_bump_patch_fails_when_post_current() -> None: sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.1.post0") + assert_curr_version_number("0.0.1post0") got_expected_exception: bool = False try: @@ -286,7 +286,7 @@ def test_bump_patch_fails_when_post_current() -> None: navigate_back_to_root_dir() -def test_bump_dev_fails_when_post_current() -> None: +def test_bump_rc_fails_when_post_current() -> None: navigate_to_test_dir_and_reset_version() # ASSERT (sanity check) assert_curr_version_number(DEFAULT_START_VERSION) @@ -294,11 +294,11 @@ def test_bump_dev_fails_when_post_current() -> None: sys.argv = ["bumpver_handler.py", "post"] bumpver_handler.main() # ASSERT (sanity check) - assert_curr_version_number("0.0.1.post0") + assert_curr_version_number("0.0.1post0") got_expected_exception: bool = False try: - sys.argv = ["bumpver_handler.py", "dev"] + sys.argv = ["bumpver_handler.py", "rc"] bumpver_handler.main() except ValueError as e: got_expected_exception = True diff --git a/src/allencell_ml_segmenter/_tests/scripts/unmodified_pyproject.toml b/src/allencell_ml_segmenter/_tests/scripts/unmodified_pyproject.toml index 1b6ab2a5..cef428db 100644 --- a/src/allencell_ml_segmenter/_tests/scripts/unmodified_pyproject.toml +++ b/src/allencell_ml_segmenter/_tests/scripts/unmodified_pyproject.toml @@ -5,7 +5,7 @@ version = "0.0.1" # https://pypi.org/project/bumpver [tool.bumpver] current_version = "0.0.1" -version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]" +version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]" commit = false tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml push = false diff --git a/src/allencell_ml_segmenter/scripts/bumpver_handler.py b/src/allencell_ml_segmenter/scripts/bumpver_handler.py index 7de9d70a..b8e2f2da 100644 --- a/src/allencell_ml_segmenter/scripts/bumpver_handler.py +++ b/src/allencell_ml_segmenter/scripts/bumpver_handler.py @@ -11,7 +11,7 @@ def main() -> None: raise ValueError("No component specified for bumping version") component: str = sys.argv[1].lower() - valid_options: set[str] = {"major", "minor", "patch", "dev", "post"} + valid_options: set[str] = {"major", "minor", "patch", "rc", "post"} if component not in valid_options: raise ValueError(f"Component must be one of {valid_options}") @@ -20,36 +20,33 @@ def main() -> None: version_components: list[str] = version.split(".") update_output: subprocess.CompletedProcess - # 4 components means we currently have a dev or post version - if len(version_components) == 4 and version_components[-1].startswith( - "dev" - ): - if component == "dev": - # increment the dev tag (e.g. 1.0.0.dev0 -> 1.0.0.dev1) + if "rc" in version_components[-1]: + if component == "rc": + # increment the rc tag (e.g. 1.0.0rc0 -> 1.0.0rc1) update_output = subprocess.run( ["bumpver", "update", "--tag-num", "-n"] ) elif component == "patch": - # finalize the patch by removing dev tag (e.g. 1.0.0.dev1 -> 1.0.0) + # finalize the patch by removing rc tag (e.g. 1.0.0rc1 -> 1.0.0) update_output = subprocess.run( ["bumpver", "update", "--tag=final", "-n"] ) else: raise ValueError( - "Cannot update major or minor version while dev version is current" + "Cannot update major or minor version while rc version is current" ) - elif len(version_components) == 4: # current version must be post + elif "post" in version_components[-1]: if component == "post": update_output = subprocess.run( ["bumpver", "update", "--tag-num", "-n"] ) else: raise ValueError("Cannot change post version to standard version") - elif len(version_components) == 3: - if component == "dev": - # increment patch and begin at dev0 (e.g. 1.0.0 -> 1.0.1.dev0) + else: + if component == "rc": + # increment patch and begin at rc0 (e.g. 1.0.0 -> 1.0.1rc0) update_output = subprocess.run( - ["bumpver", "update", "--patch", "--tag=dev", "-n"] + ["bumpver", "update", "--patch", "--tag=rc", "-n"] ) elif component == "post": update_output = subprocess.run( @@ -60,11 +57,6 @@ def main() -> None: ["bumpver", "update", f"--{component}", "-n"] ) - else: - raise ValueError( - f"Unknown version format: {version}. Expected MAJOR.MINOR.PATCH[.PYTAGNUM]" - ) - if update_output.returncode != 0: raise RuntimeError( f"bumpver exited with code {update_output.returncode}"