Skip to main content

Hear ye, hear ye, says the towncrier

GitHub Actions Codecov

towncrier is a utility to produce useful, summarised news files for your project. Rather than reading the Git history as some newer tools to produce it, or having one single file which developers all write to, towncrier reads “news fragments” which contain information useful to end users.

Philosophy

towncrier delivers the news which is convenient to those that hear it, not those that write it.

That is, by duplicating what has changed from the “developer log” (which may contain complex information about the original issue, how it was fixed, who authored the fix, and who reviewed the fix) into a “news fragment” (a small file containing just enough information to be useful to end users), towncrier can produce a digest of the changes which is valuable to those who may wish to use the software. These fragments are also commonly called “topfiles” or “newsfiles” in Twisted parlance.

towncrier works best in a development system where all merges involve closing a ticket.

Quick Start

Install from PyPI:

python3 -m pip install towncrier

In your project root, add a towncrier.toml or a pyproject.toml file (if both files exist, the first will take precedence). You can configure your project in two ways. To configure it via an explicit directory, add:

[tool.towncrier]
directory = "changes"

Alternatively, to configure it relative to a (Python) package directory, add:

[tool.towncrier]
package = "mypackage"
package_dir = "src"
filename = "NEWS.rst"

For the latter, news fragments (see “News Fragments” below) should be in a newsfragments directory under your package. Using the above example, your news fragments would be src/myproject/newsfragments/).

towncrier needs to know what version your project is, and there are three ways you can give it:

  • For Python 2/3 compatible projects, a __version__ in the top level package. This can be either a string literal, a tuple, or an Incremental version.

  • Manually passing --version=<myversionhere> when interacting with towncrier.

  • Definining a version option in a configuration file:

[tool.towncrier]
# ...
version = "1.2.3"  # project version if maintained separately

To create a new news fragment, use the towncrier create command. For example:

towncrier create 123.feature

To produce a draft of the news file, run:

towncrier build --draft

To produce the news file for real, run:

towncrier build

This command will remove the news files (with git rm) and append the built news to the filename specified by the filename configuration option, and then stage the news file changes (with git add). It leaves committing the changes up to the user.

If you wish to have content at the top of the news file (for example, to say where you can find the tickets), put your text above a rST comment that says:

.. towncrier release notes start

towncrier will then put the version notes after this comment, and leave your existing content that was above it where it is.

News Fragments

towncrier has a few standard types of news fragments, signified by the file extension. These are:

  • .feature: Signifying a new feature.

  • .bugfix: Signifying a bug fix.

  • .doc: Signifying a documentation improvement.

  • .removal: Signifying a deprecation or removal of public API.

  • .misc: A ticket has been closed, but it is not of interest to users.

The start of the filename is the ticket number, and the content is what will end up in the news file. For example, if ticket #850 is about adding a new widget, the filename would be myproject/newsfragments/850.feature and the content would be myproject.widget has been added.

Further Options

Towncrier has the following global options, which can be specified in the toml file:

[tool.towncrier]
package = ""
package_dir = "."
single_file = true  # if false, filename is formatted like `title_format`.
filename = "NEWS.rst"
directory = "directory/of/news/fragments"
version = "1.2.3"  # project version if maintained separately
name = "arbitrary project name"
template = "path/to/template.rst"
start_string = "Text used to detect where to add the generated content in the middle of a file. Generated content added after this text. Newline auto added."
title_format = "{name} {version} ({project_date})"  # or false if template includes title
issue_format = "format string for {issue} (issue is the first part of fragment name)"
underlines = "=-~"
wrap = false  # Wrap text to 79 characters
all_bullets = true  # make all fragments bullet points

If a single file is used, the content of that file gets overwritten each time.

If title_format is unspecified or an empty string, the default format will be used. If set to false, no title will be created. This can be useful if the specified template creates the title itself.

Furthermore, you can add your own fragment types using:

[tool.towncrier]
[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true

Metadata

Release files for towncrier 21.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for towncrier 21.9.0
File Size Uploaded Provenance Actions
towncrier-21.9.0.tar.gz 35.1 kB Without provenance Details for towncrier-21.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for towncrier 21.9.0
File Interpreter ABI Platform Actions
towncrier-21.9.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for towncrier-21.9.0-py2.py3-none-any.whl

Total release size: 67.7 kB

Release files / towncrier-21.9.0.tar.gz

Download URL towncrier-21.9.0.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9cb6f45c16e1a1eec9d0e7651165e7be60cd0ab81d13a5c96ca97a498ae87f48
BLAKE2b-256 checksum
How to use checksums
fcc71c7d5b8b53b6045a54ffd4dfae6893f7575f2d057463c6836e9eedb64be4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / towncrier-21.9.0-py2.py3-none-any.whl

Download URL towncrier-21.9.0-py2.py3-none-any.whl
Size 32.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fc5a88a2a54988e3a8ed2b60d553599da8330f65722cc607c839614ed87e0f92
BLAKE2b-256 checksum
How to use checksums
b0b42cba29f8485d9e90609679d80e8b259e0edd8eda12f50f0402580a88d2e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for towncrier 21.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

21.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page