-
Notifications
You must be signed in to change notification settings - Fork 9
ci: introduce towncrier for fragment-based changelog management #16
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
base: main
Are you sure you want to change the base?
Changes from all commits
ad66f6a
bc86b5d
6d05257
c061d4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # This action requires that any PR targeting the main branch should add a | ||
| # changelog fragment file in a .changelog/ directory under the affected | ||
| # package. If a changelog entry is not required, add the "Skip Changelog" | ||
| # label to disable this action. | ||
|
|
||
| name: changelog | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, labeled, unlabeled] | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| changelog: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Fetch base branch | ||
| run: git fetch origin ${{ github.base_ref }} --depth=1 | ||
|
|
||
| - name: Ensure no direct changes to CHANGELOG.md | ||
| run: | | ||
| if [[ $(git diff --name-only FETCH_HEAD -- '**/CHANGELOG.md') ]] | ||
| then | ||
| echo "CHANGELOG.md files should not be directly modified." | ||
| echo "Please add a changelog fragment file to the affected package's .changelog/ directory instead." | ||
| echo "See CONTRIBUTING.md for details." | ||
| echo "" | ||
| echo "Or add the \"Skip Changelog\" label if this job should be skipped." | ||
| false | ||
| fi | ||
|
|
||
| - name: Check for changelog fragment | ||
| env: | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| fragments=$(git diff --diff-filter=A --name-only FETCH_HEAD -- '**/.changelog/*' | grep -v '/\.gitignore$' || true) | ||
|
MikeGoldsmith marked this conversation as resolved.
|
||
| if [[ -z "$fragments" ]]; then | ||
| echo "No changelog fragment found for this PR." | ||
| echo "" | ||
| echo "Add a file named <package>/.changelog/${PR_NUMBER}.<type>" | ||
| echo "where <type> is one of: added, changed, deprecated, removed, fixed" | ||
| echo "" | ||
| echo "See CONTRIBUTING.md for details." | ||
| echo "" | ||
| echo "Or add the \"Skip Changelog\" label if this job should be skipped." | ||
| exit 1 | ||
| fi | ||
| invalid=() | ||
| while IFS= read -r f; do | ||
| base=$(basename "$f") | ||
| if [[ ! "$base" =~ ^([0-9]+)\.(added|changed|deprecated|removed|fixed)$ ]]; then | ||
| invalid+=("$f (expected <PR_NUMBER>.<type>; type one of added, changed, deprecated, removed, fixed)") | ||
| continue | ||
| fi | ||
| if [[ "${BASH_REMATCH[1]}" != "${PR_NUMBER}" ]]; then | ||
| invalid+=("$f (PR number ${BASH_REMATCH[1]} does not match this PR's number ${PR_NUMBER})") | ||
| fi | ||
| done <<< "$fragments" | ||
| if (( ${#invalid[@]} > 0 )); then | ||
| echo "Invalid changelog fragment(s):" | ||
| for msg in "${invalid[@]}"; do | ||
| echo " $msg" | ||
| done | ||
| exit 1 | ||
| fi | ||
| echo "Found changelog fragment(s):" | ||
| echo "$fragments" | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.14" | ||
|
|
||
| - name: Install towncrier | ||
| run: pip install towncrier==25.8.0 | ||
|
|
||
| - name: Preview changelogs | ||
| run: | | ||
| set -eu | ||
| for pkg in instrumentation/* util/opentelemetry-util-genai; do | ||
| [ -f "$pkg/pyproject.toml" ] || continue | ||
| grep -q "tool.towncrier" "$pkg/pyproject.toml" || continue | ||
| echo "=== $pkg ===" | ||
| (cd "$pkg" && towncrier build --draft --version Unreleased) | ||
| done | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -70,6 +70,19 @@ uv run tox -e typecheck | |||
| `typing.cast(...)`, unless the referenced type is imported at runtime. | ||||
| - Whenever applicable, all code changes should have tests that actually validate the changes. | ||||
|
|
||||
| ## Changelog | ||||
|
|
||||
| This repo uses [towncrier](https://towncrier.readthedocs.io/) to manage changelogs. | ||||
|
|
||||
| - Do not edit `CHANGELOG.md` directly — the `changelog` workflow rejects PRs that do. | ||||
| - For changes with user-visible impact, add a fragment at `<package>/.changelog/<PR_NUMBER>.<type>` | ||||
| containing a one-line description. Types: `added`, `changed`, `deprecated`, `removed`, `fixed`. | ||||
| - Don't include the PR number in the body — towncrier appends it from the filename. | ||||
| - Preview locally with `uv run tox -e changelog-preview`. | ||||
| - If the change needs no entry (pure docs or tooling), add the `Skip Changelog` label to the PR. | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might send agents on a wrong path - most contributors don't have write access but their agents might try to add labels. let's remove?
Suggested change
|
||||
|
|
||||
| See [CONTRIBUTING.md](CONTRIBUTING.md#4-update-the-changelog) for full details. | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it's already linked somewhere in this doc, no need to repeat |
||||
|
|
||||
| ## Instrumentation rules | ||||
|
|
||||
| Apply to packages under `instrumentation/`. | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !.gitignore |
Uh oh!
There was an error while loading. Please reload this page.