Skip to content

Commit

Permalink
Use towncrier
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpre committed Dec 4, 2023
1 parent addc41b commit 461e1fe
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 20 deletions.
45 changes: 25 additions & 20 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,48 @@
Changelog
*********

v1.4.0 (UNRELEASED)
+++++++++++++++++++
Changelog entries for the development version are available at
https://hyperspyui.readthedocs.io/en/latest/changes.html

v1.3.1 (2023-05-05)
+++++++++++++++++++
.. towncrier-draft-entries:: |release| [UNRELEASED]

.. towncrier release notes start
1.3.1 (2023-05-05)
++++++++++++++++++
- Fix parsing extensions when rosettasciio is not installed (`#220 <https://github.com/hyperspy/hyperspyUI/pull/220>`_)

v1.3.0 (2023-05-04)
+++++++++++++++++++
1.3.0 (2023-05-04)
++++++++++++++++++
- Update release workflow to remove deprecated github actions and use pypi API token instead of user/password (`#211 <https://github.com/hyperspy/hyperspyUI/pull/211>`_)
- Fix dependabot error when parsing github workflow (`#212 <https://github.com/hyperspy/hyperspyUI/pull/212>`_)
- Fix import marker hyperspy 2.0 (`#216 <https://github.com/hyperspy/hyperspyUI/pull/216>`_)
- Add explicit support for python 3.11 (`#218 <https://github.com/hyperspy/hyperspyUI/pull/218>`_)
- Bump version of pyqode dependencies to support pyflakes >=2.5 (`#218 <https://github.com/hyperspy/hyperspyUI/pull/218>`_)


v1.2.0 (2023-03-16)
+++++++++++++++++++
1.2.0 (2023-03-16)
++++++++++++++++++
- Pin third party action and fix tests and documentation GitHub workflow (`#206 <https://github.com/hyperspy/hyperspyUI/pull/206>`_)
- Pin pyflakes to 2.4 to keep pyqode.python working (`#206 <https://github.com/hyperspy/hyperspyUI/pull/206>`_)
- Add support for HyperSpy 2.0 (`#207 <https://github.com/hyperspy/hyperspyUI/pull/207>`_)
- Improve code quality using GitHub CodeQL and fix bugs (`#208 <https://github.com/hyperspy/hyperspyUI/pull/208>`_)

v1.1.5 (2022-04-27)
+++++++++++++++++++
1.1.5 (2022-04-27)
++++++++++++++++++
* Fix numpy deprecation warning (`#203 <https://github.com/hyperspy/hyperspyUI/pull/203>`_)
* Add support for python 3.10 (`#204 <https://github.com/hyperspy/hyperspyUI/pull/204>`_)

v1.1.4
++++++
1.1.4
+++++
* Fix doc warning add workflow to publish the code on tag (`#198 <https://github.com/hyperspy/hyperspyUI/pull/198>`_)
* Add support for matplotlib 3.4.0 and increase hyperspy, matplotlib minimum requirement (`#199 <https://github.com/hyperspy/hyperspyUI/pull/199>`_)
* Fix checking animation writer availability (`#201 <https://github.com/hyperspy/hyperspyUI/pull/201>`_)
* Drop support for python 3.6 (`#202 <https://github.com/hyperspy/hyperspyUI/pull/202>`_)

v1.1.3
++++++
1.1.3
+++++

This is a maintenance release and the main highlights are:

Expand All @@ -50,8 +55,8 @@ For a detailed list of all the changes
see `the commits in the GITHUB milestones 1.1.3
<https://github.com/hyperspy/hyperspyUI/milestone/8?closed=1>`_.

v1.1.2
++++++
1.1.2
+++++

This is a maintenance release and the main highlights are:

Expand All @@ -64,8 +69,8 @@ see `the commits in the GITHUB milestones 1.1.2
<https://github.com/hyperspy/hyperspyUI/milestone/7?closed=1>`_.


v1.1.1
++++++
1.1.1
+++++


This is a maintenance release and the main highlights are:
Expand All @@ -79,8 +84,8 @@ see `the commits in the GITHUB milestones 1.1.1
<https://github.com/hyperspy/hyperspyUI/milestone/6?closed=1>`_.


v1.1.0
++++++
1.1.0
+++++

This is a maintenance release and the main highlights are:

Expand Down
9 changes: 9 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'sphinx_toggleprompt',
'sphinx.ext.napoleon',
'IPython.sphinxext.ipython_console_highlighting',
'sphinxcontrib.towncrier',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -317,3 +318,11 @@ def run_apidoc(_):

def setup(app):
app.connect('builder-inited', run_apidoc)


# -- Options for towncrier_draft extension -----------------------------------

# Options: draft/sphinx-version/sphinx-release
towncrier_draft_autoversion_mode = "draft"
towncrier_draft_include_empty = False
towncrier_draft_working_directory = ".."
49 changes: 49 additions & 0 deletions prepare_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
import argparse
import re
import subprocess


def run_towncrier(tag):
cmd = ("towncrier", "build", "--version", tag.strip("v"))

return subprocess.call(cmd)


def update_fallback_version_in_pyproject(tag, fname="pyproject.toml"):
version = tag.strip("v").split(".")
# Default to +1 on minor version
major, minor = version[0], int(version[1]) + 1

with open(fname, "r") as file:
lines = file.readlines()

pattern = "fallback_version"
new_version = f"{major}.{minor}.dev0"
# Iterate through the lines and find the pattern
for i, line in enumerate(lines):
if re.search(pattern, line):
lines[i] = f'{pattern} = "{new_version}"\n'
break

# Write the updated content back to the file
with open(fname, "w") as file:
file.writelines(lines)

print(
f"\nNew (fallback) dev version ({new_version}) written to `pyproject.toml`.\n"
)


if __name__ == "__main__":
# Get tag argument
parser = argparse.ArgumentParser()
parser.add_argument("tag")
args = parser.parse_args()
tag = args.tag

# Update release notes
run_towncrier(tag)

# Update fallback version for setuptools_scm
update_fallback_version_in_pyproject(tag)
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ file = "COPYING.txt"
"sphinx > 5.2",
"sphinx_rtd_theme",
"sphinx-toggleprompt",
"sphinxcontrib-towncrier",
"towncrier",
]
"tests" = [
"pytest-qt",
Expand Down Expand Up @@ -106,3 +108,45 @@ exclude = ["*user_plugins*"]
[tool.setuptools_scm]
# Presence enables setuptools_scm, the version will be determine at build time from git
fallback_version = "1.4.dev0"

[tool.towncrier]
package_dir = "hyperspyui"
filename = "CHANGES.rst"
directory = "upcoming_changes/"
title_format = "{version} ({project_date})"
issue_format = "`#{issue} <https://github.com/hyperspy/hyperspyui/issues/{issue}>`_"

[[tool.towncrier.type]]
directory = "new"
name = "New features"
showcontent = true

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

[[tool.towncrier.type]]
directory = "doc"
name = "Improved Documentation"
showcontent = true

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

[[tool.towncrier.type]]
directory = "enhancements"
name = "Enhancements"
showcontent = true

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

[[tool.towncrier.type]]
directory = "maintenance"
name = "Maintenance"
showcontent = true
1 change: 1 addition & 0 deletions upcoming_changes/223.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrate to HyperSpy 2.0, drop python 2.7 and add python 3.12
1 change: 1 addition & 0 deletions upcoming_changes/224.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Consolidate packaging in ``pyproject.toml``
36 changes: 36 additions & 0 deletions upcoming_changes/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This directory contains "news fragments" which are short files that contain a small **ReST**-formatted
text that will be added to the next ``CHANGELOG``.

The ``CHANGELOG`` will be read by **users**, so this description should be aimed to hyperspy users
instead of describing internal changes which are only relevant to the developers.

Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
``<ISSUE>`` is an issue number, and ``<TYPE>`` is one of:

* ``new``: new user facing features, like new command-line options and new behavior.
* ``bugfix``: fixes a bug.
* ``doc``: documentation improvement, like rewording an entire session or adding missing docs.
* ``deprecation``: feature deprecation.
* ``enhancements``: improvement of existing functionality, usually without requiring user intervention.
* ``api``: a change which may break an existing script, such as feature removal or behavior change.
* ``maintenance``: a change related to the test suite, packaging, etc.

So for example ``1412.new.rst`` or ``2773.bugfix.rst``.

If your PR fixes an issue, use the number of the issue here. If there is no issue,
then after you submit the PR and get the PR number you can add a
changelog using that instead.

If you are not sure what issue type to use, don't hesitate to ask in your PR.

``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
other than ``new`` it is usually better to stick to a single paragraph to keep it concise. For ``new``,
it is recommended to add a hyperlink to the user guide.

To make a draft of the changelog, run from the command line:

.. code-block:: bash
$ towncrier build --draft
See https://github.com/twisted/towncrier for more details.

0 comments on commit 461e1fe

Please sign in to comment.