question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prerelease can't comply with the semver.org specification

See original GitHub issue

Commitizen only implements the normalized PEP-440 prerelease format, excluding separators between :

  • the release segment and the pre-release segment
  • the pre-release signifier and the numeral

Therefore, when using the bump command, we can’t define a version format which complies with the one defined by the semver.org specification :

“pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version.”

“Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.”

consequences

cz bump can’t be used for prereleases alongside tools that follow this specification.

Especially, this leads to an error when using the Node.js semver package.

Yet, this package is used by a bunch of other tools, like Github Automatic Release (see error message below) and conventional-changelog.

The parameter "automatic_release_tag" was not set and the current tag "v1.0.0rc1" does not appear to conform to semantic versioning.
(node:3557) UnhandledPromiseRejectionWarning: Error: The parameter "automatic_release_tag" was not set and the current tag "v1.0.0rc1" does not appear to conform to semantic versioning.
  at /home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:224465
  at Generator.next (<anonymous>)
  at /home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:221749
  at new Promise (<anonymous>)
  at n (/home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:221494)
  at /home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:224406
  at /home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:224971
  at Generator.next (<anonymous>)
  at /home/runner/work/_actions/marvinpinto/action-automatic-releases/latest/dist/index.js:1:221749
  at new Promise (<anonymous>)

details

When adding a hyphen between patch and release in the configuration, it appears in all version numbers, including not prerelease ones (e.g. v1.2.3- instead of v1.2.3).

tag_format = "v$minor.$major.$patch-$prerelease"

In addition, there doesn’t seem to be any way to add a separator (dot) between the prerelease signifier and the numeral.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
woilecommented, Mar 29, 2022

Unfortunately I haven’t had time to work on this, and I’ve just recently started working on this. But I do want to have it, because it will play well with tools that use semver like rust ecosystem or helm charts. There’s no pattern, we were relying on the version system from python.

3reactions
woilecommented, Apr 24, 2020

I’ve run some tests and semver from poetry will be useful:

In [1]: from semver.version import Version                                                                                                       

In [3]: v = Version.parse("1.0.0-alpha")                                                                                                         

In [7]: v.__dict__                                                                                                                               
Out[7]: 
{'_major': 1,
 '_precision': 3,
 '_minor': 0,
 '_patch': 0,
 '_rest': 0,
 '_text': '1.0.0-alpha',
 '_prerelease': ['alpha', 0],
 '_build': []}

In [8]: v = Version.parse("1.0.0-a0")                                                                                                            

In [9]: v                                                                                                                                        
Out[9]: <Version 1.0.0-a0>

In [10]: v.__dict__                                                                                                                              
Out[10]: 
{'_major': 1,
 '_precision': 3,
 '_minor': 0,
 '_patch': 0,
 '_rest': 0,
 '_text': '1.0.0-a0',
 '_prerelease': ['alpha', 0],
 '_build': []}

In [11]: v = Version.parse("1.0.0a0")                                                                                                            

In [12]: v.__dict__                                                                                                                              
Out[12]: 
{'_major': 1,
 '_precision': 3,
 '_minor': 0,
 '_patch': 0,
 '_rest': 0,
 '_text': '1.0.0a0',
 '_prerelease': ['alpha', 0],
 '_build': []}

It will be some work to refactor, but doable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Semantic Versioning 2.0.0 | Semantic Versioning
A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal ......
Read more >
Untangling semver with regular expressions
PRE-RELEASE : “A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the ...
Read more >
NuGet Prerelease Restrictions - versioning - Stack Overflow
now i use nuget 4.0.0 and it works as expected. So the correct answer would be: from the SemVer spec 2.0 (http://semver.org/).
Read more >
SemVer - Use semantic version numbers - metacpan.org
A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers...
Read more >
python-semver Documentation
VersionInfo(major=4, minor=0, patch=0, prerelease=None, build=None) ... The semver.org page is the authorative specification of how ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found