Skip to content

Commit f3608e0

Browse files
committed
ci(release): include manual notes in draft releases
Signed-off-by: Roel de Cort <roel.decort@adfinis.com>
1 parent 033eda5 commit f3608e0

3 files changed

Lines changed: 60 additions & 5 deletions

File tree

docs/contribute/release-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Release-please remains the source of truth for release notes. After release-plea
108108

109109
<Callout type="note" title="Human release notes">
110110

111-
Keep `CHANGELOG.md` generated by release-please. Put hand-written release summaries, migration notes, and operator-facing callouts in `release-notes/X.Y.Z.md`; the website release generator prepends that file to the generated changelog entry for the matching version.
111+
Keep `CHANGELOG.md` generated by release-please. Put hand-written release summaries, migration notes, and operator-facing callouts in `release-notes/X.Y.Z.md`; the website release generator and draft GitHub Release creation prepend that file to the generated changelog entry for the matching version.
112112

113113
</Callout>
114114

hack/ci/create-release-tag-and-draft.sh

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -euo pipefail
77
BASE_BRANCH="${BASE_BRANCH:-main}"
88
MANIFEST_FILE="${MANIFEST_FILE:-.release-please-manifest.json}"
99
CHART_FILE="${CHART_FILE:-charts/openbao-operator/Chart.yaml}"
10+
RELEASE_NOTES_DIR="${RELEASE_NOTES_DIR:-release-notes}"
1011
DRY_RUN="${DRY_RUN:-0}"
1112

1213
GH_READ_TOKEN="${GH_READ_TOKEN:-${GH_TOKEN:-}}"
@@ -74,6 +75,44 @@ sanitize_release_notes() {
7475
'
7576
}
7677

78+
manual_release_notes_path() {
79+
local version="$1"
80+
local extension path
81+
82+
for extension in mdx md; do
83+
path="${RELEASE_NOTES_DIR}/${version}.${extension}"
84+
if [[ -f "${path}" ]]; then
85+
printf '%s\n' "${path}"
86+
return 0
87+
fi
88+
done
89+
90+
return 1
91+
}
92+
93+
trim_file() {
94+
awk '
95+
{
96+
lines[NR] = $0
97+
}
98+
END {
99+
start = 1
100+
while (start <= NR && lines[start] ~ /^[[:space:]]*$/) {
101+
start++
102+
}
103+
104+
end = NR
105+
while (end >= start && lines[end] ~ /^[[:space:]]*$/) {
106+
end--
107+
}
108+
109+
for (i = start; i <= end; i++) {
110+
print lines[i]
111+
}
112+
}
113+
' "$1"
114+
}
115+
77116
gh_read() {
78117
GH_TOKEN="${GH_READ_TOKEN}" gh "$@"
79118
}
@@ -165,15 +204,31 @@ if [[ "${manifest_at_merge}" != "${version}" || "${chart_version_at_merge}" != "
165204
fi
166205

167206
notes_file="$(mktemp)"
168-
trap 'rm -f "${notes_file}"' EXIT
207+
generated_notes_file="$(mktemp)"
208+
trap 'rm -f "${notes_file}" "${generated_notes_file}"' EXIT
169209

170-
jq -r '.body // empty' <<<"${release_pr_json}" | sanitize_release_notes > "${notes_file}"
210+
jq -r '.body // empty' <<<"${release_pr_json}" | sanitize_release_notes > "${generated_notes_file}"
171211

172-
if [[ ! -s "${notes_file}" ]]; then
212+
if [[ ! -s "${generated_notes_file}" ]]; then
173213
echo "release PR #${release_pr_number} body is empty after sanitization" >&2
174214
exit 1
175215
fi
176216

217+
if manual_notes_file="$(manual_release_notes_path "${version}")"; then
218+
trim_file "${manual_notes_file}" > "${notes_file}"
219+
if [[ -s "${notes_file}" ]]; then
220+
printf '\n\n' >> "${notes_file}"
221+
fi
222+
cat "${generated_notes_file}" >> "${notes_file}"
223+
else
224+
cat "${generated_notes_file}" > "${notes_file}"
225+
fi
226+
227+
if [[ ! -s "${notes_file}" ]]; then
228+
echo "release notes for ${version} are empty" >&2
229+
exit 1
230+
fi
231+
177232
if git rev-parse -q --verify "refs/tags/${version}" >/dev/null 2>&1; then
178233
local_tag_commit="$(git rev-list -n1 "${version}")"
179234
if [[ "${local_tag_commit}" != "${merge_oid}" ]]; then

website/versioned_docs/version-0.2.0/contribute/release-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Release-please remains the source of truth for release notes. After release-plea
108108

109109
<Callout type="note" title="Human release notes">
110110

111-
Keep `CHANGELOG.md` generated by release-please. Put hand-written release summaries, migration notes, and operator-facing callouts in `release-notes/X.Y.Z.md`; the website release generator prepends that file to the generated changelog entry for the matching version.
111+
Keep `CHANGELOG.md` generated by release-please. Put hand-written release summaries, migration notes, and operator-facing callouts in `release-notes/X.Y.Z.md`; the website release generator and draft GitHub Release creation prepend that file to the generated changelog entry for the matching version.
112112

113113
</Callout>
114114

0 commit comments

Comments
 (0)