Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 6 additions & 28 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,34 +67,12 @@ jobs:
exit 1
fi

# Render changelog.d/ fragments into CHANGELOG.md and commit before the
# release is cut. Reuses the version already read from pyproject.toml, so
# there is no separate towncrier version to keep in sync. --generate-notes
# below remains as a fallback for the GitHub release body.
- name: Build changelog
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
BRANCH="${{ inputs.branch || github.event.workflow_run.head_branch }}"

# Nothing to do if there are no fragments to consume.
if ! ls changelog.d/*.md >/dev/null 2>&1; then
echo "No changelog fragments; skipping towncrier build."
exit 0
fi

pip install --quiet towncrier
towncrier build --yes --version "$VERSION"

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md changelog.d/
if ! git diff --cached --quiet; then
git commit -m "docs: update changelog for $VERSION"
git push origin "HEAD:$BRANCH"
fi

# CHANGELOG.md is rendered from changelog.d/ fragments inside the
# regeneration PR (see regenerate-library.yml), so it is already on the
# branch by the time the release is cut. Committing/pushing here would
# bypass the branch's required status checks and be rejected by the
# ruleset, so no git write happens in this workflow. --generate-notes
# below produces the GitHub release body.
- name: Create release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/regenerate-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ jobs:
sed -i "s/^version = \".*\"/version = \"$LIBRARY_VERSION\"/" pyproject.toml
uv lock

# Render changelog.d/ fragments into CHANGELOG.md here so the update rides
# the regeneration PR (and its required checks) instead of being pushed
# straight to a protected branch later. towncrier is in the dev group, so
# `uv sync --group generator` (default-groups = dev) already installed it.
- name: Build changelog
env:
LIBRARY_VERSION: ${{ github.event.inputs.library_version }}
run: |
if ls changelog.d/*.md >/dev/null 2>&1; then
uv run towncrier build --yes --version "$LIBRARY_VERSION"
else
echo "No changelog fragments; skipping towncrier build."
fi

- name: Commit changes to new branch
uses: EndBug/add-and-commit@v10
with:
Expand Down