Skip to content

Commit 027cfd8

Browse files
authored
[chore] Auto-populate release notes (#12644)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR changes the release workflow to autofill the release notes from `CHANGELOG.md` and `CHANGELOG-API.md` into the generated GH release. It makes use od `awk` and `sed` to build the release notes step by step from the changelog files. The [default chloggen template](https://github.com/open-telemetry/opentelemetry-go-build-tools/blob/c43cb0331ccdb9ff9b4a8862a3dce032147e615d/chloggen/internal/chlog/summary.tmpl) was added and a `<!--preview-version-->` tag was added to easily filter out the changelog of just the latest version. <!-- Issue number if applicable --> #### Link to tracking issue Fixes #10191 <!--Describe what testing was performed and which tests were added.--> #### Testing Tested on my fork. Release with autofilled changelog: https://github.com/mowies/opentelemetry-collector/releases/tag/v0.121.0 Workflow that did it: https://github.com/mowies/opentelemetry-collector/actions/runs/13899615357/job/38888008499 <!--Describe the documentation added.--> #### Documentation The release checklist was updated accordingly. <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: Moritz Wiesinger <[email protected]>
1 parent 8ebe098 commit 027cfd8

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

.chloggen/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ entries_dir: .chloggen
1212
# (Optional) Default: .chloggen/TEMPLATE.yaml
1313
template_yaml: .chloggen/TEMPLATE.yaml
1414

15+
summary_template: .chloggen/summary.tmpl
16+
1517
# The CHANGELOG file or files to which 'chloggen update' will write new entries
1618
# (Optional) Default filename: CHANGELOG.md
1719
change_logs:

.chloggen/summary.tmpl

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{- define "entry" -}}
2+
- `{{ .Component }}`: {{ .Note }} (
3+
{{- range $i, $issue := .Issues }}
4+
{{- if $i }}, {{ end -}}
5+
#{{ $issue }}
6+
{{- end -}}
7+
)
8+
9+
{{- if .SubText }}
10+
{{ .SubText | indent 2 }}
11+
{{- end }}
12+
{{- end }}
13+
## {{ .Version }}
14+
15+
{{- if .BreakingChanges }}
16+
17+
### 🛑 Breaking changes 🛑
18+
19+
{{- range $i, $change := .BreakingChanges }}
20+
{{- if eq $i 0}}
21+
{{end}}
22+
{{ template "entry" $change }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{- if .Deprecations }}
27+
28+
### 🚩 Deprecations 🚩
29+
30+
{{- range $i, $change := .Deprecations }}
31+
{{- if eq $i 0}}
32+
{{end}}
33+
{{ template "entry" $change }}
34+
{{- end }}
35+
{{- end }}
36+
37+
{{- if .NewComponents }}
38+
39+
### 🚀 New components 🚀
40+
41+
{{- range $i, $change := .NewComponents }}
42+
{{- if eq $i 0}}
43+
{{end}}
44+
{{ template "entry" $change }}
45+
{{- end }}
46+
{{- end }}
47+
48+
{{- if .Enhancements }}
49+
50+
### 💡 Enhancements 💡
51+
52+
{{- range $i, $change := .Enhancements }}
53+
{{- if eq $i 0}}
54+
{{end}}
55+
{{ template "entry" $change }}
56+
{{- end }}
57+
{{- end }}
58+
59+
{{- if .BugFixes }}
60+
61+
### 🧰 Bug fixes 🧰
62+
63+
{{- range $i, $change := .BugFixes }}
64+
{{- if eq $i 0}}
65+
{{end}}
66+
{{ template "entry" $change }}
67+
{{- end }}
68+
{{- end }}
69+
70+
<!-- previous-version -->

.github/workflows/sourcecode-release.yaml

+18-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,26 @@ jobs:
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414
with:
1515
fetch-depth: 0
16+
17+
- name: Prepare release notes
18+
run: |
19+
touch release-notes.md
20+
echo "### Images and binaries here: https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/${{ github.ref_name }}" >> release-notes.md
21+
echo "" >> release-notes.md
22+
echo "## End User Changelog" >> release-notes.md
23+
24+
awk '/<!-- next version -->/,/<!-- previous-version -->/' CHANGELOG.md > tmp-chlog.md # select changelog of latest version only
25+
sed '1,3d' tmp-chlog.md >> release-notes.md # delete first 3 lines of file
26+
27+
echo "" >> release-notes.md
28+
echo "## API Changelog" >> release-notes.md
29+
30+
awk '/<!-- next version -->/,/<!-- previous-version -->/' CHANGELOG-API.md > tmp-chlog-api.md # select changelog of latest version only
31+
sed '1,3d' tmp-chlog-api.md >> release-notes.md # delete first 3 lines of file
32+
1633
- name: Create Github Release
1734
run: |
18-
gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -n "### Images and binaries here: https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/${{ github.ref_name }}"
35+
gh release create ${{ github.ref_name }} -t ${{ github.ref_name }} -F release-notes.md
1936
env:
2037
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2138
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1

docs/release.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Before the release, make sure there are no open release blockers in [core](https
6363

6464
6. Wait for the new tag build to pass successfully.
6565

66-
7. A new `v0.85.0` source code release should be automatically created on Github by now. Edit it and use the contents from the CHANGELOG.md and CHANGELOG-API.md as the release's description.
66+
7. A new `v0.85.0` source code release should be automatically created on Github by now. Its description should already contain the corresponding CHANGELOG.md and CHANGELOG-API.md contents.
6767

6868
## Releasing opentelemetry-collector-contrib
6969

0 commit comments

Comments
 (0)