@@ -22,17 +22,12 @@ jobs:
2222 GH_TOKEN : ${{ secrets.RELEASE_PR_TOKEN }}
2323 DEFAULT_GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2424 PR_TITLE : " Release: develop → main"
25- PR_TEMPLATE : . github/PULL_REQUEST_TEMPLATE.md
25+ GITHUB_REPOSITORY : ${{ github.repository }}
2626 run : |
2727 set -euo pipefail
2828
2929 export GH_TOKEN="${GH_TOKEN:-$DEFAULT_GH_TOKEN}"
3030
31- if [ ! -f "$PR_TEMPLATE" ]; then
32- echo "Pull request template not found at $PR_TEMPLATE"
33- exit 1
34- fi
35-
3631 git fetch origin main --prune
3732
3833 COMMIT_COUNT="$(git rev-list --count origin/main..HEAD)"
@@ -46,11 +41,10 @@ jobs:
4641
4742 python3 - <<'PY'
4843 import os
49- import re
5044 import subprocess
5145
52- template_path = os.environ["PR_TEMPLATE"]
5346 body_file_path = os.environ["BODY_FILE"]
47+ repository = os.environ["GITHUB_REPOSITORY"]
5448
5549 # Get commits that are in develop but not in main
5650 log = subprocess.check_output(
@@ -68,51 +62,29 @@ jobs:
6862 if items:
6963 bullets = [f"- {line}" for line in items]
7064 if extra:
71- bullets.append(f"- … and {extra} more commits")
65+ bullets.append(f"- ... and {extra} more commits")
7266 else:
7367 bullets = ["- No new changes since last release"]
7468
75- with open(template_path, "r", encoding="utf-8") as f:
76- content = f.read()
77- lines = content.splitlines()
78-
79- # Find the Changes section and replace the placeholder
80- if "## Changes" in lines:
81- header_index = lines.index("## Changes")
82-
83- # Find the next section header
84- end_index = len(lines)
85- for i in range(header_index + 1, len(lines)):
86- if lines[i].startswith("## "):
87- end_index = i
88- break
89-
90- # Extract section content
91- section = lines[header_index + 1 : end_index]
92-
93- # Find and replace the placeholder bullet point
94- replaced = False
95- for idx, line in enumerate(section):
96- # Match empty bullet point (with optional whitespace)
97- if re.fullmatch(r"-\s*", line.strip()) or line.strip() == "-":
98- section = section[:idx] + bullets + section[idx + 1 :]
99- replaced = True
100- break
101-
102- if not replaced:
103- # If no placeholder found, insert bullets after empty lines/comments
104- insert_idx = 0
105- for idx, line in enumerate(section):
106- if line.strip() and not line.strip().startswith("<!--"):
107- insert_idx = idx
108- break
109- insert_idx = idx + 1
110- section = section[:insert_idx] + bullets + section[insert_idx:]
111-
112- final_lines = lines[: header_index + 1] + section + lines[end_index:]
113- else:
114- # If no Changes section exists, append one
115- final_lines = lines + ["", "## Changes", ""] + bullets
69+ summary_lines = [
70+ "This PR syncs `develop` into `main` for the next production release.",
71+ f"It includes **{len(log)}** commit(s) ahead of `main`.",
72+ ]
73+
74+ compare_url = f"https://github.com/{repository}/compare/main...develop"
75+ final_lines = [
76+ "## Release Notes",
77+ "",
78+ *summary_lines,
79+ "",
80+ "## Changes",
81+ "",
82+ *bullets,
83+ "",
84+ "## Compare",
85+ "",
86+ f"- Full diff: {compare_url}",
87+ ]
11688
11789 with open(body_file_path, "w", encoding="utf-8") as f:
11890 f.write("\n".join(final_lines).rstrip() + "\n")
0 commit comments