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

Add towncrier #618

Merged
merged 3 commits into from
Oct 1, 2018
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
1 change: 1 addition & 0 deletions anitya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@


__api_version__ = '1.0'
__version__ = '0.13.1'
4 changes: 1 addition & 3 deletions anitya/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
from . import ui, admin, api, api_v2, authentication
import anitya.lib
import anitya.mail_logging


__version__ = '0.13.1'
from anitya import __version__


def create(config=None):
Expand Down
28 changes: 25 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ Python API documentation is automatically generated from the code using Sphinx's
HTTP REST API documentation is automatically generated from the code using the
`httpdomain <https://pythonhosted.org/sphinxcontrib-httpdomain/>`_ extension.

Release notes
-------------

To add entries to the release notes, create a file in the ``news`` directory
with the ``source.type`` name format, where ``type`` is one of:

* ``feature``: for new features
* ``bug``: for bug fixes
* ``api``: for API changes
* ``dev``: for development-related changes
* ``author``: for contributor names
* ``other``: for other changes

And where the ``source`` part of the filename is:

* ``42`` when the change is described in issue ``42``
* ``PR42`` when the change has been implemented in pull request ``42``, and
there is no associated issue
* ``username`` for contributors (``author`` extention). It should be the
username part of their commit's email address.

A preview of the release notes can be generated with ``towncrier --draft``.

Development Environment
=======================
Expand Down Expand Up @@ -183,11 +205,11 @@ Release Guide

If you are a maintainer and wish to make a release, follow these steps:

1. Add any missing release notes for the release in ``docs/release-notes.rst``.

2. Change the version in ``anitya.app.__version__``. This is used to set the
1. Change the version in ``anitya.__init__.__version__``. This is used to set the
version in the documentation project and the setup.py file.

2. Generate the changelog by running ``towncrier``.

3. Commit your changes.

4. Tag a release with ``git tag -s v<version>``.
Expand Down
2 changes: 2 additions & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Release Notes
=============

.. towncrier release notes start

v0.13.1
=======

Expand Down
58 changes: 58 additions & 0 deletions news/_template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% macro issue_url(value) -%}
{%- if value.startswith("PR") -%}
`PR#{{ value[2:] }} <https://github.com/fedora-infra/fedora-messaging/pull/{{ value[2:] }}>`_
{%- elif value.startswith("C") -%}
`{{ value[1:] }} <https://github.com/fedora-infra/fedora-messaging/commit/{{ value[1:] }}>`_
{%- else -%}
`#{{ value }} <https://github.com/fedora-infra/fedora-messaging/issues/{{ value }}>`_
{%- endif -%}
{%- endmacro -%}

{% for section, _ in sections.items() %}
{% set underline = underlines[0] %}{% if section %}{{section}}
{{ underline * section|length }}{% set underline = underlines[1] %}

{% endif %}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section] and category != "author" %}
{{ definitions[category]['name'] }}
{{ underline * definitions[category]['name']|length }}

{% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category].items() %}
* {{ text }}
({% for value in values -%}
{{ issue_url(value) }}
{%- if not loop.last %}, {% endif -%}
{%- endfor %})

{% endfor %}
{% else %}
* {{ sections[section][category]['']|sort|join(', ') }}

{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.

{% else %}
{% endif %}

{% endfor %}
{% if sections[section]["author"] %}
{{definitions['author']["name"]}}
{{ underline * definitions['author']['name']|length }}
Many thanks to the contributors of bug reports, pull requests, and pull request
reviews for this release:

{% for text, values in sections[section]["author"].items() %}
* {{ text }}
{% endfor %}
{% endif %}

{% else %}
No significant changes.


{% endif %}
{% endfor %}
39 changes: 39 additions & 0 deletions news/get-authors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3

Choose a reason for hiding this comment

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

I recommend adding a docblock that explains the purpose of this script and any args it accepts (if any).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the code is copied from fedora-infra/fedora-messaging#67.
But I will add it, so this is more readable.

Choose a reason for hiding this comment

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

I didn't see a general Copyright claim on Anitya - I also recommend adding a copyright claim on this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

"""
This script is browsing through git commit history (starting at latest tag),
collects all authors of commits and creates fragment for `towncrier`_ python module.

It's meant to be run before creating a final documentation before new release.

Example:
$ python get_authors.py

.. _towncrier:
https://github.com/hawkowl/towncrier

(c) 2018 - Copyright Red Hat Inc

Authors:
Aurelien Bompard
Michal Konecny
"""


from subprocess import check_output

last_tag = check_output(["git", "describe", "--abbrev=0"], universal_newlines=True)
authors = {}
log_range = last_tag.strip() + "..HEAD"
output = check_output(["git", "log", log_range, "--format=%ae\t%an"], universal_newlines=True)
for line in output.splitlines():
email, fullname = line.split("\t")
email = email.split("@")[0].replace(".", "")
if email in authors:
continue
authors[email] = fullname

for nick, fullname in authors.items():
with open("{}.author".format(nick), "w") as f:
f.write(fullname)
f.write("\n")
1 change: 1 addition & 0 deletions news/mkonecny.author
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Michal Konečný
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[tool.towncrier]
package = "anitya"
filename = "docs/release_notes.rst"
directory = "news/"
title_format = "{version} ({project_date})"
issue_format = "{issue}"
template = "news/_template.rst"

[[tool.towncrier.type]]
directory = "api"
name = "API Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "feature"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bug"
name = "Bug Fixes"
showcontent = true

[[tool.towncrier.type]]
directory = "dev"
name = "Development Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "other"
name = "Other Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "author"
name = "Contributors"
showcontent = true
1 change: 1 addition & 0 deletions readthedocs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ sqlalchemy_schemadisplay
straight.plugin
pytoml
wtforms
towncrier
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def get_project_version():
"""Read the declared version of the project from the source code"""
version_file = "anitya/app.py"
version_file = "anitya/__init__.py"
with open(version_file, "rb") as f:
version_pattern = b"^__version__ = '(.+)'$"
match = re.search(version_pattern, f.read(), re.MULTILINE)
Expand Down