From 296f302cd0bf216ddff42ab6b1c717f1585e2333 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 19 Feb 2024 03:55:15 +0900 Subject: [PATCH] reafactor: Configure for versioning * Use bump-my-version (manage settings at pyproject.toml) * Write package version into package-root (as dynamic) * Ref version variable from sphinx-extension --- pyproject.toml | 21 ++++++++++++++++++++- src/rst_multi_refs/__init__.py | 3 ++- src/rst_multi_refs/sphinx.py | 3 ++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2170ad1..6f81c58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "rst-multi-refs" -version = "0.0.0" description = "reStrucuturedText's custom roles and role builder kit for package registries of any languages." authors = [ { name = "Kazuya Takei", email = "myself@attakei.net" } @@ -29,6 +28,7 @@ classifiers = [ "Topic :: Software Development :: Documentation", "Topic :: Text Processing :: Markup :: reStructuredText", ] +dynamic = ["version"] [project.optional-dependencies] sphinx = [ @@ -59,8 +59,27 @@ select = ["C90", "D", "E", "F", "I", "W"] [tool.ruff.lint.pydocstyle] convention = "pep257" +[tool.bumpversion] +current_version = "0.0.0" +commit = true +tag = false +message = "release: Bump version {current_version} -> {new_version}" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = "version = \"{current_version}\"" +replace = "version = \"{new_version}\"" + +[[tool.bumpversion.files]] +filename = "src/rst_multi_refs/__init__.py" +search = "__version__ = \"{current_version}\"" +replace = "__version__ = \"{new_version}\"" + [tool.hatch.metadata] allow-direct-references = true [tool.hatch.build.targets.wheel] packages = ["src/rst_multi_refs"] + +[tool.hatch.version] +path = "src/rst_multi_refs/__init__.py" diff --git a/src/rst_multi_refs/__init__.py b/src/rst_multi_refs/__init__.py index d8f80a9..02b5839 100644 --- a/src/rst_multi_refs/__init__.py +++ b/src/rst_multi_refs/__init__.py @@ -1 +1,2 @@ -"""Root of package.""" +"""Root of rst-multi-refs.""" +__version__ = "0.0.0" diff --git a/src/rst_multi_refs/sphinx.py b/src/rst_multi_refs/sphinx.py index 1a3d9c3..4a3ac62 100644 --- a/src/rst_multi_refs/sphinx.py +++ b/src/rst_multi_refs/sphinx.py @@ -2,6 +2,7 @@ from sphinx.application import Sphinx from sphinx.config import Config +from . import __version__ from .core import configure @@ -14,7 +15,7 @@ def setup(app: Sphinx): """Entrypoint as Sphinx extension.""" app.connect("config-inited", register_roles) return { - "version": "0.0.0", + "version": __version__, "env_version": 1, "parallel_read_safe": False, }