diff --git a/CHANGES.rst b/CHANGES.rst index 60b81226..65c0bd86 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,15 +2,20 @@ 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 `_) -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 `_) - Fix dependabot error when parsing github workflow (`#212 `_) - Fix import marker hyperspy 2.0 (`#216 `_) @@ -18,27 +23,27 @@ v1.3.0 (2023-05-04) - Bump version of pyqode dependencies to support pyflakes >=2.5 (`#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 `_) - Pin pyflakes to 2.4 to keep pyqode.python working (`#206 `_) - Add support for HyperSpy 2.0 (`#207 `_) - Improve code quality using GitHub CodeQL and fix bugs (`#208 `_) -v1.1.5 (2022-04-27) -+++++++++++++++++++ +1.1.5 (2022-04-27) +++++++++++++++++++ * Fix numpy deprecation warning (`#203 `_) * Add support for python 3.10 (`#204 `_) -v1.1.4 -++++++ +1.1.4 ++++++ * Fix doc warning add workflow to publish the code on tag (`#198 `_) * Add support for matplotlib 3.4.0 and increase hyperspy, matplotlib minimum requirement (`#199 `_) * Fix checking animation writer availability (`#201 `_) * Drop support for python 3.6 (`#202 `_) -v1.1.3 -++++++ +1.1.3 ++++++ This is a maintenance release and the main highlights are: @@ -50,8 +55,8 @@ For a detailed list of all the changes see `the commits in the GITHUB milestones 1.1.3 `_. -v1.1.2 -++++++ +1.1.2 ++++++ This is a maintenance release and the main highlights are: @@ -64,8 +69,8 @@ see `the commits in the GITHUB milestones 1.1.2 `_. -v1.1.1 -++++++ +1.1.1 ++++++ This is a maintenance release and the main highlights are: @@ -79,8 +84,8 @@ see `the commits in the GITHUB milestones 1.1.1 `_. -v1.1.0 -++++++ +1.1.0 ++++++ This is a maintenance release and the main highlights are: diff --git a/doc/source/conf.py b/doc/source/conf.py index 95cdf5cc..5a556511 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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. @@ -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 = ".." diff --git a/prepare_release.py b/prepare_release.py new file mode 100644 index 00000000..4fbef1f3 --- /dev/null +++ b/prepare_release.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 05d667d9..0dda9608 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,8 @@ file = "COPYING.txt" "sphinx > 5.2", "sphinx_rtd_theme", "sphinx-toggleprompt", + "sphinxcontrib-towncrier", + "towncrier", ] "tests" = [ "pytest-qt", @@ -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} `_" + + [[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 diff --git a/upcoming_changes/223.maintenance.rst b/upcoming_changes/223.maintenance.rst new file mode 100644 index 00000000..7aa358b5 --- /dev/null +++ b/upcoming_changes/223.maintenance.rst @@ -0,0 +1 @@ +Migrate to HyperSpy 2.0, drop python 2.7 and add python 3.12 diff --git a/upcoming_changes/224.maintenance.rst b/upcoming_changes/224.maintenance.rst new file mode 100644 index 00000000..e36497de --- /dev/null +++ b/upcoming_changes/224.maintenance.rst @@ -0,0 +1 @@ +Consolidate packaging in ``pyproject.toml`` \ No newline at end of file diff --git a/upcoming_changes/README.rst b/upcoming_changes/README.rst new file mode 100644 index 00000000..6de80b39 --- /dev/null +++ b/upcoming_changes/README.rst @@ -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 ``..rst``, where +```` is an issue number, and ```` 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.