as setup.cfg with version required in my ci/cd my solution is
[tool.hatch.version] path = "setup.cfg" pattern = "version = (?P<version>[^\n \r]+)"