Skip to content

Commit

Permalink
Use chloggen to generate changelog entries (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley authored May 17, 2024
1 parent c67aa3d commit fc88eaf
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 105 deletions.
18 changes: 18 additions & 0 deletions .chloggen/TEMPLATE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type:

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component:

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note:

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: []

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
26 changes: 26 additions & 0 deletions .chloggen/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The directory that stores individual changelog entries.
# Each entry is stored in a dedicated yaml file.
# - 'make chlog-new' will copy the 'template_yaml' to this directory as a new entry file.
# - 'make chlog-validate' will validate that all entry files are valid.
# - 'make chlog-update' will read and delete all entry files in this directory, and update 'changelog_md'.

# Specify as relative path from root of repo.
# (Optional) Default: .chloggen
entries_dir: .chloggen

# This file is used as the input for individual changelog entries.
# Specify as relative path from root of repo.
# (Optional) Default: .chloggen/TEMPLATE.yaml
template_yaml: .chloggen/TEMPLATE.yaml

summary_template: .chloggen/summary.tmpl

# The CHANGELOG file or files to which 'chloggen update' will write new entries
# (Optional) Default filename: CHANGELOG.md
change_logs:
user: CHANGELOG.md

# The default change_log or change_logs to which an entry should be added.
# If 'change_logs' is specified in this file, and no value is specified for 'default_change_logs',
# then 'change_logs' MUST be specified in every entry file.
default_change_logs: [user]
83 changes: 83 additions & 0 deletions .chloggen/summary.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{- define "entry" -}}
- `{{ .Component }}`: {{ .Note }} (
{{- range $i, $issue := .Issues }}
{{- if $i }}, {{ end -}}
#{{ $issue }}
{{- end -}}
)

{{- if .SubText }}
{{ .SubText | indent 2 }}
{{- end }}
{{- end }}
## {{ .Version }}

This release includes version XX.YY.ZZ of the upstream Collector components.

The individual changelogs can be found here:

vXX.YY.ZZ:
https://github.com/open-telemetry/opentelemetry-collector/releases/tag/vXX.YY.ZZ
https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/vXX.YY.ZZ

<details>
<summary>Highlights from the above changelog</summary>

-

</details>

{{- if .BreakingChanges }}

### Breaking changes

{{- range $i, $change := .BreakingChanges }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .Deprecations }}

### Deprecations

{{- range $i, $change := .Deprecations }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .NewComponents }}

### New components

{{- range $i, $change := .NewComponents }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .Enhancements }}

### Enhancements

{{- range $i, $change := .Enhancements }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}

{{- if .BugFixes }}

### Bug fixes

{{- range $i, $change := .BugFixes }}
{{- if eq $i 0}}
{{end}}
{{ template "entry" $change }}
{{- end }}
{{- end }}
88 changes: 88 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This action requires that any PR targeting the main branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip
# Changelog" label to disable this action.

name: 'Changelog'

on:
pull_request:
types: [opened, ready_for_review, synchronize, reopened, labeled, unlabeled]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
changelog:
runs-on: ubuntu-latest
if: >-
${{
!contains(github.event.pull_request.labels.*.name, 'dependencies') &&
!contains(github.event.pull_request.labels.*.name, 'Skip Changelog') &&
!contains(github.event.pull_request.title, '[chore]')
}}
env:
PR_HEAD: ${{ github.event.pull_request.head.sha }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ~1.21.6
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Ensure no changes to the CHANGELOG.md
run: |
if [[ $(git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./CHANGELOG*.md) ]]
then
echo "CHANGELOG.md should not be directly modified."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add either \"[chore]\" to the title of the pull \ request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "CHANGELOG.md was not modified."
fi
- name: Ensure ./.chloggen/*.yaml addition(s)
run: |
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./.chloggen | grep -c \\.yaml) ]]
then
echo "No changelog entry was added to the ./.chloggen/ directory."
echo "Please add a .yaml file to the ./.chloggen/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "A changelog entry was added to the ./.chloggen/ directory."
fi
- name: Validate ./.chloggen/*.yaml changes
run: |
make chlog-validate \
|| { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; }
# In order to validate any links in the yaml file, render the config to markdown
- name: Render .chloggen changelog entries
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Run markdown-link-check
run: |
markdown-link-check \
--verbose \
--config .markdown_link_check_config.json \
changelog_preview.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }
7 changes: 7 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate version
env:
TAG_NAME: ${{ github.head_ref || github.ref_name }}
run: |
# Remove leading 'v' from version
export VERSION=$(echo -n ${TAG_NAME} | cut -c 2-)
grep "version: ${VERSION}" manifest.yaml || (echo "value of 'dist.version' in manifest.yaml does not match tag version ${VERSION}, please update it" && exit 1)
- uses: actions/setup-go@v5
with:
go-version: "~1.21.3"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- This file is autogenerated. See CONTRIBUTING.md for instructions to add an entry. -->

# Changelog

<!-- next version -->
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ See https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/buil
When adding a component, an example configuration for the component must be added to `testbed/testdata/config-allcomponents.yaml`
to test that it works with a basic configuration.

### Adding a Changelog Entry

The [CHANGELOG.md](./CHANGELOG.md) files in this repo is autogenerated from
`.yaml` files in the [/.chloggen](/.chloggen) directory.

Your pull request should add a new `.yaml` file to this directory. The name of
your file can be arbitrary but must be unique since the last release.

During the release process, all `./chloggen/*.yaml` files are transcribed into
`CHANGELOG.md` and then deleted.

1. Create an entry file using `make chlog-new`. The command generates a new
file, with its name based on the current branch (e.g.
`./.chloggen/my-feature-xyz.yaml`).
2. Fill in all the fields in the generated file.
3. Run `make chlog-validate` to ensure the new file is valid.
4. Commit and push the file.

Alternately, copy `./.chloggen/TEMPLATE.yaml`, or just create your file from scratch.

## Releasing new artifacts

The [release](docs/releasing.md) and [hotfix](docs/hotfix.md) processes are described in separate documents.
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ GOMODULES = $(ALL_MODULES)

SOURCES := $(shell find internal/confmap -type f | sort )


BIN = $(BIN_DIR)/dynatrace-otel-collector
MAIN = $(BUILD_DIR)/main.go

Expand All @@ -31,6 +30,9 @@ TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES)))

GORELEASER := $(TOOLS_BIN_DIR)/goreleaser
BUILDER := $(TOOLS_BIN_DIR)/builder
CHLOGGEN := $(TOOLS_BIN_DIR)/chloggen

CHLOGGEN_CONFIG := .chloggen/config.yaml

.PHONY: build generate test clean clean-all components install-tools snapshot release
build: $(BIN)
Expand Down Expand Up @@ -70,3 +72,20 @@ $(MAIN): $(BUILDER) manifest.yaml

$(CP_FILES_DEST): $(MAIN)
cp $(notdir $@) $@

FILENAME?=$(shell git branch --show-current)
.PHONY: chlog-new
chlog-new: $(CHLOGGEN)
$(CHLOGGEN) new --config $(CHLOGGEN_CONFIG) --filename $(FILENAME)

.PHONY: chlog-validate
chlog-validate: $(CHLOGGEN)
$(CHLOGGEN) validate --config $(CHLOGGEN_CONFIG)

.PHONY: chlog-preview
chlog-preview: $(CHLOGGEN)
$(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --dry

.PHONY: chlog-update
chlog-update: $(CHLOGGEN)
$(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --version $(VERSION)
19 changes: 14 additions & 5 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ This document describes the steps to release a new version of the Dynatrace dist

## Collector release prerequisites

Ensure the manifest contains all desired collector components.

Collector components are controlled by the same `manifest.yaml`.
It is recommended that the component versions depend on the same version of the collector.
For components in the upstream collector repos, most of the time this means they will be the same version as the collector version.
Before starting a release, make a PR against to verify and update the following:

1. Ensure `manifest.yaml` contains all desired Collector components at the
desired version. It is recommended that the component versions depend on the
same minor version of the Collector. For components in the upstream Collector
repos, most of the time this means they will be the same version as the
Collector version. It is okay for bugfix versions to differ.
2. Ensure the `dist.version` key in `manifest.yaml` has the version of the
Dynatrace Collector you would like to release.
3. Ensure the changelog has been generated by running `make chlog-update
VERSION="vX.X.X"` with your desired version.
4. Update the upstream changelog links to the relevant upstream release.
5. Look through the upstream release(s) and add any highlights to the
corresponding section(s).

## Making a production release

Expand Down
6 changes: 1 addition & 5 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ toolchain go1.22.3

require (
github.com/goreleaser/goreleaser v1.26.1
go.opentelemetry.io/build-tools/chloggen v0.13.0
go.opentelemetry.io/collector/cmd/builder v0.100.0
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.25.0 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/kms v1.15.8 // indirect
Expand Down Expand Up @@ -82,7 +82,6 @@ require (
github.com/buger/jsonparser v1.1.1 // indirect
github.com/caarlos0/ctrlc v1.2.0 // indirect
github.com/caarlos0/env/v11 v11.0.0 // indirect
github.com/caarlos0/env/v9 v9.0.0 // indirect
github.com/caarlos0/go-reddit/v3 v3.0.1 // indirect
github.com/caarlos0/go-shellwords v1.0.12 // indirect
github.com/caarlos0/go-version v0.1.1 // indirect
Expand Down Expand Up @@ -136,7 +135,6 @@ require (
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/go-restruct/restruct v1.2.0-alpha // indirect
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
Expand All @@ -146,7 +144,6 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-containerregistry v0.19.1 // indirect
github.com/google/go-github/v61 v61.0.0 // indirect
github.com/google/go-github/v62 v62.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/ko v0.15.2 // indirect
Expand Down Expand Up @@ -258,7 +255,6 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
Expand Down
Loading

0 comments on commit fc88eaf

Please sign in to comment.