Skip to content

ValueError("Cannot increment a non-prerelease version with a prerelease level bump") #1442

@css-optivoy

Description

@css-optivoy

Bug Report

Description

I'm trying to bump from v. 1.6.2 to the next sensible prerelease, like 1.6.3-dev.1, but semantice-release crashes:

::ERROR:: Cannot increment a non-prerelease version with a prerelease level bump

I have the following config in pyproject.toml:

[tool.semantic_release.branches.main]
prerelease = false
prerelease_token = "dev"

[tool.semantic_release.commit_parser_options]
allowed_tags = [
    # ...
    "test",
]
minor_tags = ["feature", "feat"]
patch_tags = ["fix", "perf", "enh"]
default_bump_level = 1

A git log like:

$ git log
commit c76dcd39cd627facc8b07e9aede40474faf4833c (HEAD -> main, origin/main, origin/HEAD)
Author: css <114182330+css-optivoy@users.noreply.github.com>
Date:   Thu Apr 16 10:56:33 2026 +0200

    test: Fixes some test. (#182)

commit 655fd33399a5431b2efe544861e7489d9dfe1020 (tag: 1.6.2)
Author: semantic-release <semantic-release>
Date:   Thu Apr 16 10:31:34 2026 +0200

    1.6.2
    
    Automatically generated by python-semantic-release

Expected behavior

I expected semantic-release to create a new version bump from v. 1.6.2 to the next sensible prerelease, like 1.6.3-dev.1.

Actual behavior

$ semantic-release -vv --noop version --as-prerelease --prerelease-token=dev

[10:58:04] DEBUG    logging level set to: DEBUG                                                                                                                                    main.py:130
🛡 You are running in no-operation mode, because the '--noop' flag was supplied
           DEBUG    global cli options: GlobalCommandLineOptions(noop=True, verbosity=2, config_file='pyproject.toml', strict=False)                                               main.py:142
           INFO     Loading configuration from pyproject.toml                                                                                                                       util.py:77
           DEBUG    Trying to parse configuration pyproject.toml in TOML format                                                                                                     util.py:80
           INFO     Using group 'main' options, as '(main|master)' matches 'main'                                                                                                config.py:590
           DEBUG    hvcs token is not set                                                                                                                                        config.py:779
           WARNING  Token value is missing!                                                                                                                                      config.py:782
           DEBUG    Parsing git url 'git@github.com:.....git'                                                                                           helpers.py:245
           DEBUG    inverted tag_format '{version}' to '(?P<version>.+)'                                                                                                      translator.py:44
           DEBUG    is_forced_prerelease: as_prerelease = True, forced_level_bump = None, prerelease = False                                                                     version.py:71
           INFO     Forcing use of dev as the prerelease token     
[...]
           INFO     found 317 previous tags                                                                                                                                    algorithm.py:60
           INFO     The last full version in this branch's history was 1.6.2                                                                                                  algorithm.py:298
           INFO     The latest release in this branch's history was 1.6.2                                                                                                     algorithm.py:328
           INFO     Found 1 commits since the last release!                                                                                                                   algorithm.py:340
           DEBUG    parsed the following distinct levels from the commits since the last release: {<LevelBump.PRERELEASE_REVISION: 1>}                                        algorithm.py:378
           INFO     The type of the next release release is: prerelease_revision                                                                                              algorithm.py:384
           DEBUG    prerelease=True and the latest version 1.6.2 is not a prerelease                                                                                          algorithm.py:155
ValueError: Cannot increment a non-prerelease version with a prerelease level bump

Traceback (most recent call last):
  File "/home/user/..._env/lib/python3.13/site-packages/semantic_release/__main__.py", line 16, in main
    cli_main(args=sys.argv[1:])
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/user/..._env/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/user/..._env/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/home/user/..._env/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/user/..._env/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/..._env/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/..._env/lib/python3.13/site-packages/click/decorators.py", line 45, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/home/user/..._env/lib/python3.13/site-packages/semantic_release/cli/commands/version.py", line 537, in version
    new_version = next_version(
        repo=git_repo,
    ...<4 lines>...
        allow_zero_version=runtime.allow_zero_version,
    )
  File "/home/user/..._env/lib/python3.13/site-packages/semantic_release/version/algorithm.py", line 395, in next_version
    return _increment_version(
        latest_version=latest_version,
    ...<5 lines>...
        allow_zero_version=allow_zero_version,
    )
  File "/home/user/..._env/lib/python3.13/site-packages/semantic_release/version/algorithm.py", line 166, in _increment_version
    raise ValueError(
        "Cannot increment a non-prerelease version with a prerelease level bump"
    )

::ERROR:: Cannot increment a non-prerelease version with a prerelease level bump

Environment

  • Operating System (w/ version): Ubuntu 25.10
  • Python version: Python 3.13.2
  • Pip version: pip 25.1
  • Semantic-release version: 10.5.3
  • Build tool (w/ version): NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagewaiting for initial maintainer review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions