Skip to content

Use Towncrier to Manage Changelog #1102

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
56 changes: 46 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,53 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

prepare-release-notes:
name: Prepare Release Notes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v5
- name: Install towncrier
run: pip install towncrier==24.8.0
- name: Install pandoc
run: |
sudo apt-get install -y pandoc
- name: Install pytest-asyncio
run: pip install .
- name: Compile Release Notes Draft
if: ${{ !contains(github.ref, 'refs/tags/') }}
run: |
set -e
version=$(python ./tools/get-version.py)
towncrier build --draft --version "${version}" > release-notes.rst
- name: Extract release notes from Git tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
set -e
git for-each-ref github.ref --format='%(contents)' > release-notes.rst
# Strip PGP signature from signed tags
sed -i "/-----BEGIN PGP SIGNATURE-----/,/-----END PGP SIGNATURE-----\n/d" release-notes.rst
- name: Convert Release Notes to Markdown
run: |
pandoc -s -o release-notes.md release-notes.rst
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-notes.md
path: release-notes.md

deploy:
name: Deploy
environment: release
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [lint, check]
needs: [lint, check, prepare-release-notes]
runs-on: ubuntu-latest
steps:
- name: Install pandoc
run: |
sudo apt-get install -y pandoc
- name: Checkout
uses: actions/checkout@v4
- name: Download distributions
uses: actions/download-artifact@v4
with:
Expand All @@ -147,20 +181,22 @@ jobs:
- name: Collected dists
run: |
tree dist
- name: Convert README.rst to Markdown
run: |
pandoc -s -o README.md README.rst
- name: PyPI upload
uses: pypa/gh-action-pypi-publish@v1.12.4
with:
attestations: true
packages-dir: dist
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Download Release Notes
uses: actions/download-artifact@v4
with:
name: release-notes.md
path: release-notes.md
- name: GitHub Release
uses: ncipollo/release-action@v1
with:
name: pytest-asyncio ${{ needs.lint.outputs.version }}
artifacts: dist/*
bodyFile: README.md
bodyFile: release-notes.md
prerelease: ${{ needs.lint.outputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
Empty file added changelog.d/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions docs/reference/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

This project uses [*towncrier*](https://towncrier.readthedocs.io/) for changlog management and the changes for the upcoming release can be found in <https://github.com/pytest-dev/pytest-asyncio/tree/main/changelog.d/>.

.. towncrier release notes start

0.26.0 (2025-03-25)
===================
- Adds configuration option that sets default event loop scope for all tests `#793 <https://github.com/pytest-dev/pytest-asyncio/issues/793>`_
Expand Down
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,39 @@ parallel = true

[tool.coverage.report]
show_missing = true

[tool.towncrier]
directory = "changelog.d"
filename = "docs/reference/changelog.rst"
title_format = "`{version} <https://github.com/pytest-dev/pytest-asyncio/tree/{version}>`_ - {project_date}"
issue_format = "`#{issue} <https://github.com/pytest-dev/pytest-asyncio/issues/{issue}>`_"

[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true

[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true

[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true

[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true
Loading