-
Notifications
You must be signed in to change notification settings - Fork 874
ci: introduce towncrier to generate changelog from fragments #5187
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
f664c36
fd3eef6
9f096aa
988c2e7
21c4873
0bd5867
5ddece8
b9306e7
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 @@ | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # 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. | ||
| # This action requires that any PR targeting the main branch should add a | ||
| # changelog fragment file in the .changelog/ directory. If a changelog entry | ||
| # is not required, add the "Skip Changelog" label to disable this action. | ||
|
|
||
| name: changelog | ||
|
|
||
|
|
@@ -22,18 +22,40 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check for CHANGELOG changes | ||
| - name: Fetch base branch | ||
| run: git fetch origin ${{ github.base_ref }} --depth=1 | ||
|
|
||
| - name: Ensure no direct changes to CHANGELOG.md | ||
| run: | | ||
| # Only the latest commit of the feature branch is available | ||
| # automatically. To diff with the base branch, we need to | ||
| # fetch that too (and we only need its latest commit). | ||
| git fetch origin ${{ github.base_ref }} --depth=1 | ||
| if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]] | ||
| if [[ $(git diff --name-only FETCH_HEAD -- 'CHANGELOG.md') ]] | ||
| then | ||
| echo "A CHANGELOG was modified. Looks good!" | ||
| else | ||
| echo "No CHANGELOG was modified." | ||
| echo "Please add a CHANGELOG entry, or add the \"Skip Changelog\" label if not required." | ||
| echo "CHANGELOG.md should not be directly modified." | ||
| echo "Please add a changelog fragment file to the .changelog/ directory instead." | ||
| echo "" | ||
| echo "Create a fragment with:" | ||
| echo " tox -e new-changelog -- ${{ github.event.pull_request.number }} TYPE \"Description\"" | ||
| echo "where TYPE is one of: added, changed, deprecated, removed, fixed" | ||
| echo "" | ||
| echo "Or add the \"Skip Changelog\" label if this job should be skipped." | ||
| false | ||
| fi | ||
|
|
||
| - name: Install towncrier | ||
| run: pip install towncrier | ||
|
|
||
| - name: Check for changelog fragment | ||
| run: | | ||
| if ! towncrier check --compare-with origin/${{ github.base_ref }}; then | ||
| echo "" | ||
| echo "No changelog fragment found for this PR." | ||
| echo "" | ||
| echo "Create a fragment with:" | ||
| echo " tox -e new-changelog -- ${{ github.event.pull_request.number }} TYPE \"Description\"" | ||
| echo "where TYPE is one of: added, changed, deprecated, removed, fixed" | ||
| echo "" | ||
| echo "Or add the \"Skip Changelog\" label if this job should be skipped." | ||
|
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. Can you add a new step here to build and print the changelog? Just for ourselves to see when we want, and to save time from running the command locally to see how it renders? |
||
| false | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ## Version {{ versiondata.version }} ({{ versiondata.date }}) | ||
|
|
||
| {% for section, _ in sections.items() %} | ||
| {%- if section %}{{ section }}{% endif -%} | ||
|
|
||
| {% if sections[section] %} | ||
| {% for category, val in definitions.items() if category in sections[section] %} | ||
| ### {{ definitions[category]['name'] }} | ||
|
|
||
| {% for text, values in sections[section][category].items() %} | ||
| {% if "\n - " in text or '\n * ' in text %} | ||
| {%- set main_text, sub_items = text.split('\n', 1) %} | ||
| - {{ main_text }} ({{ values|join(', ') }}) | ||
| {% if sub_items %} | ||
| {{- sub_items }} | ||
| {% endif %} | ||
| {% else %} | ||
| - {{ text }} ({{ values|join(', ') }}) | ||
| {% endif %} | ||
| {% endfor %} | ||
|
|
||
| {% endfor %} | ||
| {% endif %} | ||
| {% endfor %} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.