Skip to content

Commit 11a55b9

Browse files
authored
automation - add changelog and release automation (#86)
Add a new Github workflow for releases that automates the generation of a draft GH release with changelog notes. Pull requests will be required to add new file to at .changelog/<pr_number>.txt with a changelog message or label with skip-changelog to bypass the check. See CONTRIBUTING.md for more details. This backfills the .changelog directory with entries for changes since v0.14.0. The original CHANGELOG.md file has been moved into .changelog/.pre-0.15.0-changelog.md to preserve this information.
1 parent 69177af commit 11a55b9

File tree

9 files changed

+226
-31
lines changed

9 files changed

+226
-31
lines changed

CHANGELOG.md renamed to .changelog/.pre-0.15.0-changelog.md

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
# Change Log
2-
All notable changes to this project will be documented in this file.
3-
This project adheres to [Semantic Versioning](http://semver.org/).
4-
5-
## [Unreleased]
62

7-
### Added
3+
> [!NOTE]
4+
> This file contains the historical release notes for versions prior to v0.15.0.
5+
> It is no longer updated. Please see the GitHub release notes for newer
6+
> releases.
87
9-
### Changed
10-
11-
- Update build to use Go 1.22. [#78](https://github.com/elastic/stream/pull/78)
12-
13-
### Fixed
14-
15-
- Check for nil packet and transport layer when streaming pcap files [#88](https://github.com/elastic/stream/pull/88)
16-
17-
### Removed
8+
This project adheres to [Semantic Versioning](http://semver.org/).
189

1910
## [0.14.0]
2011

@@ -26,29 +17,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2617

2718
- Update build to use Go 1.20. [#75](https://github.com/elastic/stream/pull/75)
2819

29-
### Fixed
30-
31-
### Removed
32-
3320
## [0.13.0]
3421

3522
### Added
3623

24+
- Added support for azure eventhub output: [#58](https://github.com/elastic/stream/pull/58)
3725
- Added `exit-on-unmatched-rule` flag: [#63](https://github.com/elastic/stream/pull/63)
3826
- Added sequences to the http server: [#64](https://github.com/elastic/stream/pull/64)
3927

40-
### Changed
41-
42-
### Fixed
43-
44-
### Removed
45-
46-
## [0.12.0]
47-
48-
### Added
49-
50-
- Added support for azure eventhub output: [#58](https://github.com/elastic/stream/pull/58)
51-
5228
## [0.11.0]
5329

5430
### Added
@@ -148,7 +124,12 @@ no longer contain a trailing newline. [#31](https://github.com/elastic/stream/pu
148124
- Added pcap and log file inputs.
149125
- Added udp, tcp, and tls outputs.
150126

151-
[Unreleased]: https://github.com/elastic/stream/compare/v0.8.0...HEAD
127+
[0.14.0]: https://github.com/elastic/stream/releases/tag/v0.14.0
128+
[0.13.0]: https://github.com/elastic/stream/releases/tag/v0.13.0
129+
[0.11.0]: https://github.com/elastic/stream/releases/tag/v0.11.0
130+
[0.10.0]: https://github.com/elastic/stream/releases/tag/v0.10.0
131+
[0.9.1]: https://github.com/elastic/stream/releases/tag/v0.9.1
132+
[0.9.0]: https://github.com/elastic/stream/releases/tag/v0.9.0
152133
[0.8.0]: https://github.com/elastic/stream/releases/tag/v0.8.0
153134
[0.7.0]: https://github.com/elastic/stream/releases/tag/v0.7.0
154135
[0.6.2]: https://github.com/elastic/stream/releases/tag/v0.6.2
@@ -160,3 +141,4 @@ no longer contain a trailing newline. [#31](https://github.com/elastic/stream/pu
160141
[0.2.0]: https://github.com/elastic/stream/releases/tag/v0.2.0
161142
[0.1.0]: https://github.com/elastic/stream/releases/tag/v0.1.0
162143
[0.0.1]: https://github.com/elastic/stream/releases/tag/v0.0.1
144+

.changelog/78.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
build: Releases are now built with Go 1.22.
3+
```

.changelog/88.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
pcap input: Check for nil packet and transport layer when streaming pcap files.
3+
```

.github/release/changelog.gotmpl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .NotesByType.note -}}
2+
NOTES:
3+
{{range .NotesByType.note -}}
4+
* {{ template "note" .}}
5+
{{ end -}}
6+
{{- end -}}
7+
8+
{{- if .NotesByType.deprecation -}}
9+
DEPRECATIONS:
10+
{{range .NotesByType.deprecation -}}
11+
* {{ template "note" .}}
12+
{{ end -}}
13+
{{- end -}}
14+
15+
{{- if index .NotesByType "breaking-change" -}}
16+
BREAKING CHANGES:
17+
{{range index .NotesByType "breaking-change" -}}
18+
* {{ template "note" .}}
19+
{{ end -}}
20+
{{- end -}}
21+
22+
{{- $features := combineTypes .NotesByType.feature (index .NotesByType "new-resource" ) (index .NotesByType "new-datasource") (index .NotesByType "new-data-source") -}}
23+
{{- if $features }}
24+
FEATURES:
25+
{{range $features | sort -}}
26+
* {{ template "note" . }}
27+
{{ end -}}
28+
{{- end -}}
29+
30+
{{- $improvements := combineTypes .NotesByType.improvement .NotesByType.enhancement -}}
31+
{{- if $improvements }}
32+
IMPROVEMENTS:
33+
{{range $improvements | sort -}}
34+
* {{ template "note" . }}
35+
{{ end -}}
36+
{{- end -}}
37+
38+
{{- if .NotesByType.bug }}
39+
BUG FIXES:
40+
{{range .NotesByType.bug -}}
41+
* {{ template "note" . }}
42+
{{ end -}}
43+
{{- end -}}

.github/release/release-note.gotmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- define "note" -}}
2+
{{if eq "new-resource" .Type}}**New Resource:** {{else if eq "new-datasource" .Type}}**New Data Source:** {{ end }}{{.Body}} ([GH-{{- .Issue -}}])
3+
{{- end -}}

.github/scripts/check-changelog.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
set -uo pipefail
3+
4+
if [[ -z "${PR_NUMBER}" ]]; then
5+
echo "PR_NUMBER must be set."
6+
exit 1
7+
fi
8+
9+
if [[ -z "${BASE_REF}" ]]; then
10+
echo "BASE_REF must be set."
11+
exit 1
12+
fi
13+
14+
docs_url="https://github.com/GoogleCloudPlatform/magic-modules/blob/2834761fec3acbf35cacbffe100530f82eada650/.ci/RELEASE_NOTES_GUIDE.md#expected-format"
15+
16+
# Version of https://github.com/hashicorp/go-changelog.
17+
go_changelog_version=ba40b3a
18+
go_changelog_check="go run github.com/hashicorp/go-changelog/cmd/changelog-check@${go_changelog_version}"
19+
20+
expected_changelog_file=.changelog/${PR_NUMBER}.txt
21+
22+
# Verify file is present.
23+
if [ ! -e "${expected_changelog_file}" ]; then
24+
echo "Changelog file missing at ${expected_changelog_file}.
25+
26+
Please add a changelog entry following the format described [here](${docs_url}).
27+
28+
If this change does not require a changelog entry then label the pull request
29+
with skip-changelog.
30+
" >> $GITHUB_STEP_SUMMARY
31+
exit 1
32+
fi
33+
34+
# Check the format.
35+
if ! ${go_changelog_check} "${expected_changelog_file}"; then
36+
echo "Changelog format is invalid. See build log." >> $GITHUB_STEP_SUMMARY
37+
exit 1
38+
fi
39+
40+
echo "Changelog is valid." >> $GITHUB_STEP_SUMMARY

.github/workflows/changelog.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: changelog
3+
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, labeled, unlabeled]
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
check:
15+
if: "!contains(github.event.pull_request.labels.*.name, 'skip-changelog')"
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: changelog
21+
env:
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
BASE_REF: ${{ github.event.pull_request.base.ref }}
24+
run: .github/scripts/check-changelog.sh

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: release
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: Tag name (e.g. v1.2.3) for this version (does not need to exist).
9+
required: true
10+
type: string
11+
last_release:
12+
description: Last release tag.
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
draft:
21+
permissions:
22+
contents: write
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Need full history.
28+
29+
- name: release notes
30+
run: >-
31+
go run github.com/hashicorp/go-changelog/cmd/changelog-build@ba40b3a
32+
-changelog-template .github/release/changelog.gotmpl
33+
-note-template .github/release/release-note.gotmpl
34+
-entries-dir ./.changelog
35+
-last-release "${{ inputs.last_release }}"
36+
-this-release HEAD | tee /tmp/release-notes.txt
37+
38+
cat << EOF >> /tmp/release-notes.txt
39+
DOWNLOAD:
40+
41+
- \`docker pull docker.elastic.co/observability/stream:${{ inputs.version }}\`
42+
EOF
43+
44+
- name: draft GH release
45+
env:
46+
GH_TOKEN: ${{ github.token }}
47+
run: >-
48+
gh release create "${{ inputs.version }}"
49+
--draft
50+
--notes-file /tmp/release-notes.txt
51+
--title "${{ inputs.version }}"

CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing
2+
3+
Pull requests are welcomed. You must
4+
5+
- Sign the Elastic [Contributor License Agreement](https://www.elastic.co/contributor-agreement).
6+
- Include a changelog entry at `.changelog/{pr-number}.txt` with your pull
7+
request. Or label the PR with `skip-changelog` if it is a non-user facing
8+
change (test fixes, CI changes, etc.).
9+
- Include tests that demonstrate the change is working.
10+
11+
The `.changelog/{pr-number}.txt` changelog file must follow a Markdown code
12+
block format like
13+
14+
~~~
15+
```release-note:enhancement
16+
webhook: Added support for HTTP response headers.
17+
```
18+
~~~
19+
20+
You must use one of these types:
21+
22+
- `release-note:enhancement`
23+
- `release-note:bug`
24+
- `release-note:deprecation`
25+
- `release-note:breaking-change`
26+
- `release-note:new-resource`
27+
28+
The changelog file may contain more than one Markdown code block if there is
29+
more than one change.
30+
31+
~~~
32+
```release-note:enhancement
33+
http mock server: Added minify_json template helper function for minifying static JSON.
34+
```
35+
36+
```release-note:bug
37+
http mock server: Fixed YAML unmarshaling of numbers.
38+
```
39+
~~~
40+
41+
## Releasing
42+
43+
To create a new release, use the release workflow in GitHub actions. This will create a new draft
44+
release in GitHub releases with a changelog. After the job completes, review the draft and if
45+
everything is correct, publish the release. When the release is published, GitHub will create the
46+
git tag.

0 commit comments

Comments
 (0)