-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
69177af
commit 11a55b9
Showing
9 changed files
with
226 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
build: Releases are now built with Go 1.22. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
pcap input: Check for nil packet and transport layer when streaming pcap files. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{- if .NotesByType.note -}} | ||
NOTES: | ||
{{range .NotesByType.note -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.deprecation -}} | ||
DEPRECATIONS: | ||
{{range .NotesByType.deprecation -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if index .NotesByType "breaking-change" -}} | ||
BREAKING CHANGES: | ||
{{range index .NotesByType "breaking-change" -}} | ||
* {{ template "note" .}} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- $features := combineTypes .NotesByType.feature (index .NotesByType "new-resource" ) (index .NotesByType "new-datasource") (index .NotesByType "new-data-source") -}} | ||
{{- if $features }} | ||
FEATURES: | ||
{{range $features | sort -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- $improvements := combineTypes .NotesByType.improvement .NotesByType.enhancement -}} | ||
{{- if $improvements }} | ||
IMPROVEMENTS: | ||
{{range $improvements | sort -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} | ||
|
||
{{- if .NotesByType.bug }} | ||
BUG FIXES: | ||
{{range .NotesByType.bug -}} | ||
* {{ template "note" . }} | ||
{{ end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- define "note" -}} | ||
{{if eq "new-resource" .Type}}**New Resource:** {{else if eq "new-datasource" .Type}}**New Data Source:** {{ end }}{{.Body}} ([GH-{{- .Issue -}}]) | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
set -uo pipefail | ||
|
||
if [[ -z "${PR_NUMBER}" ]]; then | ||
echo "PR_NUMBER must be set." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${BASE_REF}" ]]; then | ||
echo "BASE_REF must be set." | ||
exit 1 | ||
fi | ||
|
||
docs_url="https://github.com/GoogleCloudPlatform/magic-modules/blob/2834761fec3acbf35cacbffe100530f82eada650/.ci/RELEASE_NOTES_GUIDE.md#expected-format" | ||
|
||
# Version of https://github.com/hashicorp/go-changelog. | ||
go_changelog_version=ba40b3a | ||
go_changelog_check="go run github.com/hashicorp/go-changelog/cmd/changelog-check@${go_changelog_version}" | ||
|
||
expected_changelog_file=.changelog/${PR_NUMBER}.txt | ||
|
||
# Verify file is present. | ||
if [ ! -e "${expected_changelog_file}" ]; then | ||
echo "Changelog file missing at ${expected_changelog_file}. | ||
Please add a changelog entry following the format described [here](${docs_url}). | ||
If this change does not require a changelog entry then label the pull request | ||
with skip-changelog. | ||
" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi | ||
|
||
# Check the format. | ||
if ! ${go_changelog_check} "${expected_changelog_file}"; then | ||
echo "Changelog format is invalid. See build log." >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
fi | ||
|
||
echo "Changelog is valid." >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
name: changelog | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, labeled, unlabeled] | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
check: | ||
if: "!contains(github.event.pull_request.labels.*.name, 'skip-changelog')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: changelog | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
BASE_REF: ${{ github.event.pull_request.base.ref }} | ||
run: .github/scripts/check-changelog.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Tag name (e.g. v1.2.3) for this version (does not need to exist). | ||
required: true | ||
type: string | ||
last_release: | ||
description: Last release tag. | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
draft: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Need full history. | ||
|
||
- name: release notes | ||
run: >- | ||
go run github.com/hashicorp/go-changelog/cmd/changelog-build@ba40b3a | ||
-changelog-template .github/release/changelog.gotmpl | ||
-note-template .github/release/release-note.gotmpl | ||
-entries-dir ./.changelog | ||
-last-release "${{ inputs.last_release }}" | ||
-this-release HEAD | tee /tmp/release-notes.txt | ||
cat << EOF >> /tmp/release-notes.txt | ||
DOWNLOAD: | ||
- \`docker pull docker.elastic.co/observability/stream:${{ inputs.version }}\` | ||
EOF | ||
- name: draft GH release | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create "${{ inputs.version }}" | ||
--draft | ||
--notes-file /tmp/release-notes.txt | ||
--title "${{ inputs.version }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Contributing | ||
|
||
Pull requests are welcomed. You must | ||
|
||
- Sign the Elastic [Contributor License Agreement](https://www.elastic.co/contributor-agreement). | ||
- Include a changelog entry at `.changelog/{pr-number}.txt` with your pull | ||
request. Or label the PR with `skip-changelog` if it is a non-user facing | ||
change (test fixes, CI changes, etc.). | ||
- Include tests that demonstrate the change is working. | ||
|
||
The `.changelog/{pr-number}.txt` changelog file must follow a Markdown code | ||
block format like | ||
|
||
~~~ | ||
```release-note:enhancement | ||
webhook: Added support for HTTP response headers. | ||
``` | ||
~~~ | ||
|
||
You must use one of these types: | ||
|
||
- `release-note:enhancement` | ||
- `release-note:bug` | ||
- `release-note:deprecation` | ||
- `release-note:breaking-change` | ||
- `release-note:new-resource` | ||
|
||
The changelog file may contain more than one Markdown code block if there is | ||
more than one change. | ||
|
||
~~~ | ||
```release-note:enhancement | ||
http mock server: Added minify_json template helper function for minifying static JSON. | ||
``` | ||
```release-note:bug | ||
http mock server: Fixed YAML unmarshaling of numbers. | ||
``` | ||
~~~ | ||
|
||
## Releasing | ||
|
||
To create a new release, use the release workflow in GitHub actions. This will create a new draft | ||
release in GitHub releases with a changelog. After the job completes, review the draft and if | ||
everything is correct, publish the release. When the release is published, GitHub will create the | ||
git tag. |