-
Notifications
You must be signed in to change notification settings - Fork 82
chore: FXC-4066-improve-changelog-management #3292
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
Merged
yaugenst-flex
merged 1 commit into
develop
from
FXC-4066-improve-changelog-management-to-reduce-merge-conflicts-and-make-better-changelogs
Feb 18, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
164 changes: 164 additions & 0 deletions
164
.github/workflows/tidy3d-python-client-build-changelog-pr.yml
This file contains hidden or 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,164 @@ | ||
| name: public/tidy3d/python-client-build-changelog-pr | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_workflow: | ||
| description: 'Set to true to build changelog and create a PR' | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
| source_branch: | ||
| description: 'Source branch to checkout and build changelog from' | ||
| required: false | ||
| type: string | ||
| default: 'develop' | ||
| target_branch: | ||
| description: 'Target branch for the generated changelog PR' | ||
| required: false | ||
| type: string | ||
| default: 'develop' | ||
| release_version: | ||
| description: 'Optional release version override (for example: 2.11.0)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| release_date: | ||
| description: 'Optional release date override in YYYY-MM-DD (defaults to UTC today)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| previous_version: | ||
| description: 'Optional previous release version override (for example: 2.10.2)' | ||
| required: false | ||
| type: string | ||
| default: '' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-changelog-pr: | ||
| if: github.event.inputs.run_workflow == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ github.event.inputs.source_branch || 'develop' }} | ||
| fetch-depth: 0 | ||
| submodules: false | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install Poetry | ||
| uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1 | ||
| with: | ||
| version: 2.1.1 | ||
| virtualenvs-create: true | ||
| virtualenvs-in-project: true | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| set -e | ||
| poetry install --extras dev --no-interaction | ||
|
|
||
| - name: Build changelog | ||
| id: build-changelog | ||
| env: | ||
| INPUT_RELEASE_VERSION: ${{ github.event.inputs.release_version }} | ||
| INPUT_RELEASE_DATE: ${{ github.event.inputs.release_date }} | ||
| INPUT_PREVIOUS_VERSION: ${{ github.event.inputs.previous_version }} | ||
| SOURCE_BRANCH: ${{ github.event.inputs.source_branch || 'develop' }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| if [[ ! -d changelog.d ]]; then | ||
| echo "changelog.d/ directory not found; skipping changelog build." | ||
| echo "changes_detected=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| fragment_count=$(find changelog.d -maxdepth 1 -type f -name '*.md' ! -name 'README.md' ! -name 'template.md' | wc -l) | ||
| if [[ "$fragment_count" -eq 0 ]]; then | ||
| echo "No changelog fragments found in changelog.d/." | ||
| echo "changes_detected=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| relver="${INPUT_RELEASE_VERSION}" | ||
| if [[ -z "$relver" ]]; then | ||
| relver=$(poetry version -s | sed -E 's/\.dev[0-9]+$//') | ||
| fi | ||
| relver=$(echo "$relver" | sed -E 's/^v//') | ||
| if [[ -z "$relver" ]]; then | ||
| echo "::error::Release version is empty after normalization." | ||
| exit 1 | ||
| fi | ||
|
|
||
| reldate="${INPUT_RELEASE_DATE}" | ||
| if [[ -z "$reldate" ]]; then | ||
| reldate=$(date -u +%F) | ||
| fi | ||
|
|
||
| prevver="${INPUT_PREVIOUS_VERSION}" | ||
| prevver=$(echo "$prevver" | sed -E 's/^v//') | ||
| if [[ -z "$prevver" ]]; then | ||
| prevver=$(git tag --merged HEAD --list 'v*' --sort=-v:refname | sed 's/^v//' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${relver}$" | head -n1 || true) | ||
| fi | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| if [[ -z "$prevver" ]]; then | ||
| prevver=$(grep -E '^## \[[0-9]+\.[0-9]+\.[0-9]+\] - ' CHANGELOG.md | sed -E 's/^## \[([0-9]+\.[0-9]+\.[0-9]+)\].*/\1/' | grep -v "^${relver}$" | head -n1 || true) | ||
| fi | ||
|
|
||
| safe_source_branch=$(echo "$SOURCE_BRANCH" | tr '/ ' '--') | ||
|
|
||
| echo "Building changelog for version ${relver} on ${reldate}" | ||
| poetry run towncrier build --yes --version "${relver}" --date "${reldate}" | ||
|
|
||
| if [[ -n "$prevver" ]]; then | ||
| poetry run python scripts/changelog_refs.py --version "${relver}" --previous-version "${prevver}" | ||
| else | ||
| poetry run python scripts/changelog_refs.py --version "${relver}" | ||
| fi | ||
|
|
||
| if git diff --quiet -- CHANGELOG.md changelog.d; then | ||
| echo "changes_detected=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changes_detected=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| previous_version_output="${prevver}" | ||
| if [[ -z "$previous_version_output" ]]; then | ||
| previous_version_output="auto-detected" | ||
| fi | ||
| echo "release_version=${relver}" >> "$GITHUB_OUTPUT" | ||
| echo "release_date=${reldate}" >> "$GITHUB_OUTPUT" | ||
| echo "previous_version=${previous_version_output}" >> "$GITHUB_OUTPUT" | ||
| echo "safe_source_branch=${safe_source_branch}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.build-changelog.outputs.changes_detected == 'true' | ||
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "chore(changelog): :robot: build release notes for ${{ steps.build-changelog.outputs.release_version }}" | ||
| title: "chore(changelog): :robot: build release notes for ${{ steps.build-changelog.outputs.release_version }}" | ||
| body: | | ||
| This pull request was automatically generated by a GitHub Action. | ||
|
|
||
| It builds `CHANGELOG.md` from Towncrier fragments and updates compare reference links. | ||
|
|
||
| Source branch: `${{ github.event.inputs.source_branch || 'develop' }}` | ||
| Target branch: `${{ github.event.inputs.target_branch || 'develop' }}` | ||
| Version: `${{ steps.build-changelog.outputs.release_version }}` | ||
| Previous version: `${{ steps.build-changelog.outputs.previous_version }}` | ||
| Date: `${{ steps.build-changelog.outputs.release_date }}` | ||
| branch: "chore/build-changelog-${{ steps.build-changelog.outputs.safe_source_branch }}-${{ github.run_id }}" | ||
| base: "${{ github.event.inputs.target_branch || 'develop' }}" | ||
| delete-branch: true | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.