Skip to content

Commit 2be9f36

Browse files
authored
Use towncrier for changelog generation (#2736)
* Use towncrier for changelog generation * Generate unreleased changelog * Fix towncrier command * Fix issue links * Don't do unreleased changelog on tagged builds * Rename 1234.doc.rst to 2736.doc.rst * Change existing release notes entry to new format * Update contributing guide for new release notes system * Update pull request template for new changelog system
1 parent a260ae9 commit 2be9f36

12 files changed

+55
-27
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ TODO:
44
* [ ] Add unit tests and/or doctests in docstrings
55
* [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
66
* [ ] New/modified features documented in `docs/user-guide/*.rst`
7-
* [ ] Changes documented in `docs/release-notes.rst`
7+
* [ ] Changes documented as a new file in `changes/`
88
* [ ] GitHub Actions have all passed
99
* [ ] Test coverage is 100% (Codecov passes)

.github/labeler.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
needs release notes:
2-
- all: ['!docs/release-notes.rst']
1+
- needs release notes:
2+
- all:
3+
- changed-files:
4+
- any-glob-to-any-file: 'changes/*.rst'

.github/workflows/needs_release_notes.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ on:
44
- pull_request_target
55

66
jobs:
7-
triage:
7+
labeler:
88
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} && ${{ github.event.pull_request.user.login != 'pre-commit-ci[bot]' }}
9+
permissions:
10+
contents: read
11+
pull-requests: write
912
runs-on: ubuntu-latest
1013
steps:
1114
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ repos:
4949
rev: v1.8.0
5050
hooks:
5151
- id: numpydoc-validation
52+
- repo: https://github.com/twisted/towncrier
53+
rev: 23.11.0
54+
hooks:
55+
- id: towncrier-check

.readthedocs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.12"
7+
jobs:
8+
pre_build:
9+
- |
10+
if [ "$READTHEDOCS_VERSION_TYPE" != "tag" ];
11+
then
12+
towncrier build --version Unreleased --yes;
13+
fi
714
815
sphinx:
916
configuration: docs/conf.py

changes/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.gitignore

changes/2681.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added backwards compatibility for Zarr format 2 structured arrays.

changes/2736.doc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Changed the machinery for creating changelog entries.
2+
Now individual entries should be added as files to the `changes` directory in the `zarr-python` repository, instead of directly to the changelog file.

changes/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Writing a changelog entry
2+
-------------------------
3+
4+
Please put a new file in this directory named `xxxx.<type>.rst`, where
5+
6+
- `xxxx` is the pull request number associated with this entry
7+
- `<type>` is one of:
8+
- feature
9+
- bugfix
10+
- doc
11+
- removal
12+
- misc
13+
14+
Inside the file, please write a short description of what you have changed, and how it impacts users of `zarr-python`.

docs/developers/contributing.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ The documentation consists both of prose and API documentation. All user-facing
216216
and functions are included in the API documentation, under the ``docs/api`` folder
217217
using the `autodoc <https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html>`_
218218
extension to sphinx. Any new features or important usage information should be included in the
219-
user-guide (``docs/user-guide``). Any changes should also be included in the release
220-
notes (``docs/release-notes.rst``).
219+
user-guide (``docs/user-guide``). Any changes should also be included as a new file in the
220+
:file:`changes` directory.
221221

222222
The documentation can be built locally by running::
223223

@@ -335,11 +335,9 @@ Release procedure
335335

336336
Pre-release
337337
"""""""""""
338-
1. Make sure that all pull requests which will be
339-
included in the release have been properly documented in
340-
:file:`docs/release-notes.rst`.
341-
2. Rename the "Unreleased" section heading in :file:`docs/release-notes.rst`
342-
to the version you are about to release.
338+
1. Make sure that all pull requests which will be included in the release
339+
have been properly documented as changelog files in :file:`changes`.
340+
2. Run ``towncrier build --version x.y.z`` to create the changelog.
343341

344342
Releasing
345343
"""""""""
@@ -352,7 +350,7 @@ appropriate suffix (e.g. `v0.0.0a1` or `v0.0.0rc2`).
352350

353351
Set the description of the release to::
354352

355-
See release notes https://zarr.readthedocs.io/en/stable/release.html#release-0-0-0
353+
See release notes https://zarr.readthedocs.io/en/stable/release-notes.html#release-0-0-0
356354

357355
replacing the correct version numbers. For pre-release versions,
358356
the URL should omit the pre-release suffix, e.g. "a1" or "rc1".

docs/release-notes.rst

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
Release notes
22
=============
33

4-
Unreleased
5-
----------
4+
.. towncrier release notes start
65
7-
Bug fixes
8-
~~~~~~~~~
9-
10-
* Backwards compatibility for Zarr format 2 structured arrays (:issue:`2134`)
11-
12-
Features
13-
~~~~~~~~
14-
15-
Documentation
16-
~~~~~~~~~~~~~
17-
18-
Other
19-
~~~~~
206
217
3.0.1 (Jan. 17, 2025)
228
---------------------

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ test = [
8585
]
8686
optional = ["rich", "universal-pathlib"]
8787
docs = [
88+
# Doc building
8889
'sphinx==8.1.3',
8990
'sphinx-autobuild>=2021.3.14',
9091
'sphinx-autoapi==3.4.0',
@@ -94,6 +95,9 @@ docs = [
9495
'sphinx-reredirects',
9596
'pydata-sphinx-theme',
9697
'numpydoc',
98+
# Changelog generation
99+
'towncrier',
100+
# Optional dependencies to run examples
97101
'numcodecs[msgpack]',
98102
'rich',
99103
's3fs',
@@ -415,3 +419,9 @@ checks = [
415419
"PR05",
416420
"PR06",
417421
]
422+
423+
[tool.towncrier]
424+
directory = 'changes'
425+
filename = "docs/release-notes.rst"
426+
underlines = ["-", "~", "^"]
427+
issue_format = ":issue:`{issue}`"

0 commit comments

Comments
 (0)