Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introducing towncrier to generate changelog from fragments #4382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

emdneto
Copy link
Member

@emdneto emdneto commented Jan 9, 2025

Fix #4307
Hopefully, also Fix #4309

Description

Towncrier is a tool adopted in some well-known python projects to generate release notes from fragments. In otel-python we are always dealing with CHANGELOG.mdconflicts during rebases, specially after releases. So, this can help us with it since now we have a changelog entry for each PR in the .changelog directory. This is similar to chloggen adopted in opentelemetry-collector.

How it works:

  1. Creating a Changelog Fragment:

    • Contributors add a changelog entry under the .changelog directory in the format <PR_NUMBER>.<CATEGORY>, where <CATEGORY> can be added, changed, fixed, etc.
    • For example, a PR #1234 fixing a bug would create a file named ./.changelog/1234.fixed containing a short description of the change.
    • Every PR should include at least one changelog fragment unless explicitly exempted (e.g., PR's with Skip Changelog).
  2. Releasing:

    • During the release, we run towncrier build --yes. This command:
      • Gathers all fragments in the .changelog directory.
      • Renders the release notes.
      • Updates CHANGELOG.md with the generated content.

The configuration is pretty simple and we can customize the changelog as we want using jinja templates and also customize the category names.

I tested the changes using https://github.com/nektos/act: act -W '.github/workflows/changelog.yml' --eventpath event.json

{
    "act": true,
    "env": {
        "GITHUB_REF_NAME": "main"
    },
    "pull_request": {
      "number": 4371,
      "head": {
        "ref": "xyz",
        "sha": "1234567890abcdef1234567890abcdef12345678"
      },
      "base": {
        "ref": "main"
      },
      "user": {
        "login": "opentelemetrybot"
      }
    }
  }

If you checkout this branch and run towncrier build --yes --version=1.30.0/0.51b0
The generated changelog for this branch will be:

## Version 1.30.0/0.51b0 (2025-01-09)

### Changed

- sdk: don't log or print warnings when the SDK has been disabled
  ([#4371](https://github.com/open-telemetry/opentelemetry-python/pull/4371))

### Added

- Add Python 3.13 support
  ([#4353](https://github.com/open-telemetry/opentelemetry-python/pull/4353))
- Add `attributes` field in `metrics.get_meter` wrapper function
  ([#4364](https://github.com/open-telemetry/opentelemetry-python/pull/4364))

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
@emdneto emdneto added Skip Changelog PRs that do not require a CHANGELOG.md entry and removed Skip Changelog PRs that do not require a CHANGELOG.md entry labels Jan 9, 2025
@emdneto emdneto marked this pull request as ready for review January 9, 2025 13:37
@emdneto emdneto requested a review from a team as a code owner January 9, 2025 13:37
@@ -78,3 +71,32 @@ jobs:
--body "$message." \
--head $branch \
--base $GITHUB_REF_NAME

- uses: actions/checkout@v4
Copy link
Member Author

@emdneto emdneto Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably leave this for another PR to not introduce too many changes at this moment

@emdneto emdneto added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
1 participant