You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/07/13 18:07:15 UTC

(tooling-releases-client) branch main updated: Use message templates by default when announcing a release

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-releases-client.git


The following commit(s) were added to refs/heads/main by this push:
     new 7a378cf  Use message templates by default when announcing a release
7a378cf is described below

commit 7a378cfcceea073f143307752d2ef01588762f4b
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon Jul 13 19:07:00 2026 +0100

    Use message templates by default when announcing a release
---
 COMMANDS.md                 |  3 ++-
 pyproject.toml              |  4 ++--
 src/atrclient/client.py     | 26 +++++++++++++++++++++-----
 src/atrclient/models/api.py |  4 +++-
 tests/cli_workflow.t        |  5 +++--
 tests/test_all.py           | 40 ++++++++++++++++++++++++++++++++++++++++
 uv.lock                     |  4 ++--
 7 files changed, 73 insertions(+), 13 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md
index f96a323..fb7b115 100644
--- a/COMMANDS.md
+++ b/COMMANDS.md
@@ -46,7 +46,8 @@ Announce a release.
 ╭─ Parameters ─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │    REVISION --revision                                                                                               │
 │ *  --mailing-list -m    [required]                                                                                   │
-│    --body -b                                                                                                         │
+│    --body -b            Literal announcement email body. If omitted, the server renders it from the project's        │
+│                         announce email template.                                                                     │
 │    --path-suffix -p                                                                                                  │
 ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
 ```
diff --git a/pyproject.toml b/pyproject.toml
index 917c145..532baec 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,7 +11,7 @@ build-backend = "hatchling.build"
 
 [project]
 name            = "apache-trusted-releases"
-version         = "0.20260713.1541"
+version         = "0.20260713.1553"
 description     = "ATR CLI and Python API"
 readme          = "README.md"
 requires-python = ">=3.12"
@@ -87,4 +87,4 @@ filterwarnings = [
 ]
 
 [tool.uv]
-exclude-newer = "2026-07-13T15:41:00Z"
+exclude-newer = "2026-07-13T15:53:00Z"
diff --git a/src/atrclient/client.py b/src/atrclient/client.py
index a18b346..73f4a3d 100755
--- a/src/atrclient/client.py
+++ b/src/atrclient/client.py
@@ -100,7 +100,17 @@ def app_announce(
     revision: str | None = None,
     *,
     mailing_list: Annotated[str, cyclopts.Parameter(alias="-m", name="--mailing-list")],
-    body: Annotated[str | None, cyclopts.Parameter(alias="-b", name="--body")] = None,
+    body: Annotated[
+        str | None,
+        cyclopts.Parameter(
+            alias="-b",
+            name="--body",
+            help=(
+                "Literal announcement email body. If omitted, the server renders it from "
+                "the project's announce email template."
+            ),
+        ),
+    ] = None,
     path_suffix: Annotated[str | None, cyclopts.Parameter(alias="-p", name="--path-suffix")] = None,
 ) -> None:
     announce_args = models.api.ReleaseAnnounceArgs(
@@ -108,15 +118,21 @@ def app_announce(
         version=models.safe.VersionKey(version),
         revision=models.safe.RevisionNumber(revision) if revision else None,
         email_to=mailing_list,
-        body=body or f"Release {project} {version} has been announced.",
+        body=body,
         path_suffix=models.safe.RelPath(path_suffix) if path_suffix else None,
     )
     announce = api.release_announce(announce_args)
     if not announce.success:
         show.error_and_exit("Failed to announce release.")
-    # The result only contains a success bool
-    # Therefore the ReleaseAnnounceArgs actually contain most of the information
-    show.json_or_message(announce_args, "Announcement sent.")
+    # The result only contains a success bool, so the request arguments contain most of the information.
+    announce_record = announce_args.model_dump(mode="json")
+    success_message = "Announcement sent."
+    if body is None:
+        announce_record["body_rendered_by_server"] = True
+        success_message = (
+            "Announcement sent with a body rendered by the server from the project's announce email template."
+        )
+    show.json_or_message(announce_record, success_message)
 
 
 @APP_API.command(name="get", help="GET a resource from the API.")
diff --git a/src/atrclient/models/api.py b/src/atrclient/models/api.py
index a691704..c64cae5 100644
--- a/src/atrclient/models/api.py
+++ b/src/atrclient/models/api.py
@@ -665,7 +665,9 @@ class ReleaseAnnounceArgs(schema.Strict):
     version: safe.VersionKey = schema.example("1.0.0")
     revision: safe.RevisionNumber | None = schema.default_example(None, "00005")
     email_to: str = schema.example("dev@example.apache.org")
-    body: str = schema.example("The Apache Example team is pleased to announce the release of Example 1.0.0...")
+    body: str | None = schema.default_example(
+        None, "The Apache Example team is pleased to announce the release of Example 1.0.0..."
+    )
     path_suffix: safe.OptionalRelPath = schema.example("example/1.0.0")
 
 
diff --git a/tests/cli_workflow.t b/tests/cli_workflow.t
index d90440f..30438de 100644
--- a/tests/cli_workflow.t
+++ b/tests/cli_workflow.t
@@ -70,8 +70,9 @@ Distribution recorded.
 $ atr distribution list test-client 0.3+cli
 <.skip.>react@18.2.0<.skip.>
 
-$ atr announce test-client 0.3+cli 00005 -m "<!user!>@apache.org" -b "Release test-client 0.3+cli has been announced."
-Announcement sent.
+<# omit body to exercise the server-side announce template #>
+$ atr announce test-client 0.3+cli 00005 -m "<!user!>@apache.org"
+Announcement sent with a body rendered by the server from the project's announce email template.
 
 <# tidy up #>
 * atr dev delete test-client 0.3+cli
diff --git a/tests/test_all.py b/tests/test_all.py
index dbee555..4130907 100755
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -19,6 +19,7 @@
 
 from __future__ import annotations
 
+import json
 import os
 import pathlib
 import re
@@ -84,6 +85,45 @@ def test_app_checks_status_non_draft_phase(
         assert "Checks are only performed during the draft phase." in captured.out
 
 
+def test_app_announce_serializes_template_default_and_literal_body(
+    capsys: pytest.CaptureFixture[str], fixture_config_env: pathlib.Path
+) -> None:
+    config.write(
+        {
+            "atr": {"host": "example.invalid"},
+            "output": {"json": True},
+            "tokens": {"jwt": "dummy_jwt_token"},
+        }
+    )
+    announce_url = "https://example.invalid/api/release/announce"
+    captured_requests: list[dict[str, Any]] = []
+    response_payload = {"endpoint": "/release/announce", "success": True}
+
+    def capture_request(_url: Any, **kwargs: Any) -> aioresponses.CallbackResult:
+        captured_requests.append(kwargs["json"])
+        return aioresponses.CallbackResult(status=201, payload=response_payload)
+
+    with aioresponses.aioresponses() as mock:
+        mock.post(announce_url, callback=capture_request)
+        mock.post(announce_url, callback=capture_request)
+        client.app_announce("test-project", "2.3.1", mailing_list="announce@example.apache.org")
+        default_record = json.loads(capsys.readouterr().out)
+        client.app_announce(
+            "test-project",
+            "2.3.1",
+            mailing_list="announce@example.apache.org",
+            body="Custom announcement body",
+        )
+        custom_record = json.loads(capsys.readouterr().out)
+
+    assert captured_requests[0]["body"] is None
+    assert default_record["body"] is None
+    assert default_record["body_rendered_by_server"] is True
+    assert captured_requests[1]["body"] == "Custom announcement body"
+    assert custom_record["body"] == "Custom announcement body"
+    assert "body_rendered_by_server" not in custom_record
+
+
 def test_app_checks_status_verbose(capsys: pytest.CaptureFixture[str], fixture_config_env: pathlib.Path) -> None:
     client.app_set("atr.host", "example.invalid")
     client.app_set("tokens.jwt", "dummy_jwt_token")
diff --git a/uv.lock b/uv.lock
index 17b94a5..576b348 100644
--- a/uv.lock
+++ b/uv.lock
@@ -3,7 +3,7 @@ revision = 3
 requires-python = ">=3.12"
 
 [options]
-exclude-newer = "2026-07-13T15:41:00Z"
+exclude-newer = "2026-07-13T15:53:00Z"
 
 [[package]]
 name = "aiohappyeyeballs"
@@ -151,7 +151,7 @@ wheels = [
 
 [[package]]
 name = "apache-trusted-releases"
-version = "0.20260713.1541"
+version = "0.20260713.1553"
 source = { editable = "." }
 dependencies = [
     { name = "aiohttp" },


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org