Repository: SFDO-Tooling/CumulusCI
Pull request #3550 (2023-02-28 02:44:43)

Allow use of static release notes on GitHub


Patch:
diff --git a/cumulusci/tasks/github/release.py b/cumulusci/tasks/github/release.py
index dcbca6274..bda170314 100644
--- a/cumulusci/tasks/github/release.py
+++ b/cumulusci/tasks/github/release.py
@@ -24,6 +24,9 @@ class CreateRelease(BaseGithubTask):
             "required": False,
         },
         "message": {"description": "The message to attach to the created git tag"},
+        "release_content": {
+            "description": "The content to include as the release body. Note: github_release_notes will overwrite this content, if used."
+        },
         "dependencies": {
             "description": "List of dependencies to record in the tag message."
         },
@@ -107,9 +110,14 @@ class CreateRelease(BaseGithubTask):
         prerelease = tag_name.startswith(self.project_config.project__git__prefix_beta)
 
         # Create the Github Release
-        release = repo.create_release(
-            tag_name=tag_name, name=version, prerelease=prerelease
-        )
+        release_parameters = {
+            "tag_name": tag_name,
+            "name": version,
+            "prerelease": prerelease,
+        }
+        if "release_content" in self.options:
+            release_parameters["body"] = self.options["release_content"]
+        release = repo.create_release(**release_parameters)
         self.return_values = {
             "tag_name": tag_name,
             "name": version,
diff --git a/docs/release-notes.md b/docs/release-notes.md
index a2e1cd3a6..d55842a13 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -1,5 +1,7 @@
 # Generate Release Notes
 
+## Using Automatic Release Note Generation
+
 The `github_release_notes` task fetches the text from Pull Requests that
 were merged between two given tags. The task then searches for specific
 titles (Critical Changes, Changes, Issues Closed, New Metadata,
@@ -51,3 +53,38 @@ the [default
 parsers](https://github.com/SFDO-Tooling/CumulusCI/blob/671a0e88cef79e9aeefe1e2b835816cd8141bdbb/cumulusci/cumulusci.yml#L1154)
 that come with CumulusCI.
 ```
+
+## Using Static Release Notes
+
+In some cases, you may wish to use static text as your release notes instead of aggregating them
+from Pull Request content. You can do that by making customizations in your `cumulusci.yml`.
+
+Customize the `github_release` task to include your static content:
+
+```yaml
+tasks:
+    github_release:
+        options:
+            release_content: |
+                # This is my top-level heading
+
+                Here is some body content.
+```
+
+Note that you may use Markdown, provided you indent the content as shown and
+utilize the `|` indicator, which marks a YAML block.
+
+Then, turn off the `github_release_notes` task, where you don't want it to run:
+
+```yaml
+flows:
+    release_beta:
+        steps:
+            3:
+                task: None
+```
+
+You can repeat this configuration for any or all of the flows `release_beta`, `release_production`,
+`release_2gp_beta`, `release_2gp_production`, `release_unlocked_beta`, and `release_unlocked_production`.
+You may choose to customize only the production flows if you want to use auto-generated release notes
+for your beta releases.


Test patch:
diff --git a/cumulusci/tasks/github/tests/test_release.py b/cumulusci/tasks/github/tests/test_release.py
index 9fabe24eb..f528e8982 100644
--- a/cumulusci/tasks/github/tests/test_release.py
+++ b/cumulusci/tasks/github/tests/test_release.py
@@ -90,6 +90,7 @@ class TestCreateRelease(GithubApiTestMixin):
                         "version": "1.0",
                         "version_id": "04t000000000000",
                         "dependencies": [{"namespace": "foo", "version": "1.0"}],
+                        "release_content": "foo release",
                         "package_type": "1GP",
                         "tag_prefix": "release/",
                     }
@@ -108,6 +109,7 @@ class TestCreateRelease(GithubApiTestMixin):
         # confirm we didn't create a prerelease
         release_request = json.loads(responses.calls._calls[-1].request.body)
         assert not release_request["prerelease"]
+        assert release_request["body"] == "foo release"
 
     @responses.activate
     def test_run_task__release_already_exists(self):