Skip to content
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

Use keep a changelog categories for towncrier #745

Merged
Merged
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
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,21 @@ An [HTML coverage report](htmlcov/index.html) will be generated.
Refer to the [tox.ini](tox.ini) file for further options.

## Using towncrier to automatically produce the changelog
### Before opening a PR
To be able to automatically produce the changelog for a release a file for each
### Before merging a pull request
To be able to automatically produce the changelog for a release one file for each
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"To be able to automatically produce the changelog for a release, one file for each..."

pull request (also called news fragment) needs to be added to the folder
`changelog.d/`.
The name of the file consists of three parts seperated by a period:
1. The identifier, either the issue number this pull request is refering to or if
there is no related issue a `+` followed by a unique short description.
2. The type of the change, we use `critical`, `added`, `changed` and `fixed`.

The name of the file consists of three parts separated by a period:
1. The identifier: either the issue number (in case the pull request fixes that issue)
or the pull request number. If we don't want to add a link to the resulting changelog
entry then a `+` followed by a unique short description.
2. The type of the change: we use `security`, `removed`, `deprecated`, `added`,
`changed` and `fixed`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tempting to also have dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but can't they all be organized into either added, changed or removed? :)

3. The file suffix, e.g. `.md`, towncrier does not care which suffix a fragment has.

So an example for a file name linked to an issue would be `214.added.md` or for a file
without corresponding issue `+fixed-pagination-bug.fixed.md`.
So an example for a file name related to an issue/pull request would be `214.added.md`
or for a file without corresponding issue `+fixed-pagination-bug.fixed.md`.

This file can either be created manually with a file name as specified above and the
changelog text as content or one can use towncrier to create such a file as following:
Expand All @@ -248,8 +251,8 @@ changelog text as content or one can use towncrier to create such a file as foll
$ towncrier create -c "Changelog content" 214.added.md
```

When opening a PR there will be a check to make sure that a news fragment is added, it
will fail if it is missing.
When opening a pull request there will be a check to make sure that a news fragment is
added and it will fail if it is missing.

### Before a release
To add all content from the `changelog.d/` folder to the changelog file simply run
Expand All @@ -258,10 +261,12 @@ $ towncrier build --version {version}
```
This will also delete all files in `changelog.d/`.

To preview what the addition to the changelog file would look like add the flag `--draft`.
To preview what the addition to the changelog file would look like add the flag
`--draft`. This will not delete any files or change `CHANGELOG.md`. It will only output
the preview in the terminal.

A few other helpful flags:
- `date DATE` - set the date of the release, default is today
- `keep` - keep all news fragments
- `keep` - do not delete the files in `changelog.d/`

More information about [towncrier](https://towncrier.readthedocs.io).
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,18 @@ issue_format = "[#{issue}](https://github.com/Uninett/Argus/issues/{issue})"
wrap = true

[[tool.towncrier.type]]
directory = "critical"
name = "Critical"
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]]
Expand Down
Loading