From df918766b07a55a697f7bf85153cd7bc5854ccf8 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 27 Sep 2023 19:54:38 +0200 Subject: [PATCH 1/3] Use 'hatch version' instead of manually updating the version. --- noxfile.py | 7 ++++--- pyproject.toml | 5 ++++- src/antsibull_docs_parser/__init__.py | 8 ++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index d150647..e43ff10 100644 --- a/noxfile.py +++ b/noxfile.py @@ -177,7 +177,9 @@ def bump(session: nox.Session): f"Either {fragment_file} must already exist, or two positional arguments must be provided." ) install(session, "antsibull-changelog[toml]", "hatch") - _repl_version(session, version) + current_version = session.run("hatch", "version", silent=True).strip() + if version != current_version: + session.run("hatch", "version", version) if len(session.posargs) > 1: fragment = session.run( "python", @@ -223,7 +225,6 @@ def publish(session: nox.Session): check_no_modifications(session) install(session, "hatch") session.run("hatch", "publish", *session.posargs) - version = session.run("hatch", "version", silent=True).strip() - _repl_version(session, f"{version}.post0") + session.run("hatch", "version", "post") session.run("git", "add", "pyproject.toml", external=True) session.run("git", "commit", "-m", "Post-release version bump.", external=True) diff --git a/pyproject.toml b/pyproject.toml index 73862e8..27e1468 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "hatchling.build" [project] name = "antsibull-docs-parser" -version = "1.0.0.post0" +dynamic = ["version"] description = "Python library for processing Ansible documentation markup" readme = "README.md" requires-python = ">=3.6.1" @@ -74,6 +74,9 @@ dev = [ "nox", ] +[tool.hatch.version] +path = "src/antsibull_docs_parser/__init__.py" + [tool.isort] profile = "black" diff --git a/src/antsibull_docs_parser/__init__.py b/src/antsibull_docs_parser/__init__.py index 7547f6e..ad09609 100644 --- a/src/antsibull_docs_parser/__init__.py +++ b/src/antsibull_docs_parser/__init__.py @@ -2,3 +2,11 @@ # https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2020, Ansible Project + +""" +Library for processing Ansible documentation markup. +""" + +__version__ = "1.0.0.post0" + +__all__ = ("__version__",) From bd7b30eb46a15ff2460c85bba5cb96570dd5c00f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 6 Feb 2024 23:50:53 +0100 Subject: [PATCH 2/3] Cleanup; commit the file which now contains the version. --- noxfile.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/noxfile.py b/noxfile.py index e43ff10..bdf95aa 100644 --- a/noxfile.py +++ b/noxfile.py @@ -110,17 +110,6 @@ def create_vectors(session: nox.Session): ) -def _repl_version(session: nox.Session, new_version: str): - with open("pyproject.toml", "r+") as fp: - lines = tuple(fp) - fp.seek(0) - for line in lines: - if line.startswith("version = "): - line = f'version = "{new_version}"\n' - fp.write(line) - fp.truncate() - - def test_no_modifications(session: nox.Session) -> bool: modified = session.run( "git", @@ -189,7 +178,13 @@ def bump(session: nox.Session): ) with open(fragment_file, "w") as fp: print(fragment, file=fp) - session.run("git", "add", "pyproject.toml", fragment_file, external=True) + session.run( + "git", + "add", + "src/antsibull_docs_parser/__init__.py", + fragment_file, + external=True, + ) session.run("git", "commit", "-m", f"Prepare {version}.", external=True) session.run("antsibull-changelog", "release") session.run( @@ -198,9 +193,9 @@ def bump(session: nox.Session): "CHANGELOG.rst", "changelogs/changelog.yaml", "changelogs/fragments/", - # pyproject.toml is not committed in the last step + # __init__.py is not committed in the last step # when the release_summary fragment is created manually - "pyproject.toml", + "src/antsibull_docs_parser/__init__.py", external=True, ) install(session, ".") # Smoke test @@ -226,5 +221,5 @@ def publish(session: nox.Session): install(session, "hatch") session.run("hatch", "publish", *session.posargs) session.run("hatch", "version", "post") - session.run("git", "add", "pyproject.toml", external=True) + session.run("git", "add", "src/antsibull_docs_parser/__init__.py", external=True) session.run("git", "commit", "-m", "Post-release version bump.", external=True) From 4bcd26732c906efa623d335ef41895d664cc1122 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 8 Feb 2024 16:38:59 +0100 Subject: [PATCH 3/3] Provide version to antsibull-changelog. --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index bdf95aa..3e95f3c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -186,7 +186,7 @@ def bump(session: nox.Session): external=True, ) session.run("git", "commit", "-m", f"Prepare {version}.", external=True) - session.run("antsibull-changelog", "release") + session.run("antsibull-changelog", "release", "--version", version) session.run( "git", "add",