How can I keep poetry and commitizen versions synced?

1k views Asked by At

I have a pyproject.toml with

[tool.poetry]
name = "my-project"
version = "0.1.0"

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.0"

I add a new feature and commit with commit message

feat: add parameter for new feature

That's one commit.

Then I call

commitizen bump

Commitizen will recognize a minor version increase, update my pyproject.toml, and commit again with the updated pyproject.toml and a tag 0.2.0.

That's a second commit.

But now my pyproject.toml is "out of whack" (assuming I want my build version in sync with my git tags).

[tool.poetry]
name = "my-project"
version = "0.1.0"

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.2.0"

I'm two commits in, one tagged, and things still aren't quite right. Is there workflow to keep everything aligned?

1

There are 1 answers

1
Gary Yu On BEST ANSWER

refer to support-for-pep621 and version_files

you can add "pyproject.toml:^version" to pyproject.toml:

[tool.commitizen]
version_files = [
    "pyproject.toml:^version"
]