From ed76f2f879d576ace92d5bce86dc4851d49dfd6d Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Fri, 1 Dec 2023 19:54:03 +0100 Subject: [PATCH] Use towncrier to manage release notes --- .gitignore | 1 + .readthedocs.yaml | 13 +++++++----- CHANGES.rst | 8 +++++--- doc/conf.py | 8 ++++++++ pyproject.toml | 50 +++++++++++++++++++++++++++++++++++++++++++++- releasing_guide.md | 8 ++++---- 6 files changed, 75 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index ccb49562c..9b2aef230 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ doc/_build/* doc/auto_examples/* +doc/sg_execution_times.rst build/* dist/* *egg-info* diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 015d38882..f11b9ac62 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,6 +10,9 @@ build: os: ubuntu-22.04 tools: python: "3.11" + jobs: + post_checkout: + - git fetch --unshallow || true # Build documentation in the docs/ directory with Sphinx sphinx: @@ -20,8 +23,8 @@ formats: - htmlzip python: - install: - - method: pip - path: . - extra_requirements: - - doc + install: + - method: pip + path: . + extra_requirements: + - doc diff --git a/CHANGES.rst b/CHANGES.rst index 97ecc327c..3012caab3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,10 +2,12 @@ Changelog ********* Changelog entries for the development version are available at -https://holospy.readthedocs.io/en/latest/changes.html +https://exspy.readthedocs.io/en/latest/changes.html -0.1.dev0 (UNRELEASED) -===================== + +.. towncrier-draft-entries:: |release| [UNRELEASED] + +.. towncrier release notes start - Enable ``signal_range`` arguments when using ``subpixel=True`` in :py:meth:`~.signals.EELSSpectrum.align_zero_loss_peak` (`#7 `_) - Support for tabulated :ref:`Generalised Oscillator Strengths (GOS) ` using the diff --git a/doc/conf.py b/doc/conf.py index 7c4ea7c78..b6b553998 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -42,6 +42,7 @@ "sphinx.ext.intersphinx", "sphinx.ext.napoleon", "sphinx_gallery.gen_gallery", + "sphinxcontrib.towncrier", ] linkcheck_ignore = [ @@ -147,3 +148,10 @@ copybutton_prompt_text = r">>> |\.\.\. " copybutton_prompt_is_regexp = True + +# -- 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/pyproject.toml b/pyproject.toml index 89b1fc936..689697b14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,8 @@ file = "LICENSE" "sphinx-design", "sphinx-favicon", "sphinx-gallery", + "sphinxcontrib-towncrier", + "towncrier", ] "tests" = [ "pytest >= 5.0", @@ -96,7 +98,10 @@ force-exclude = ''' [tool.coverage.run] branch = true source = ["hyperspy"] -omit = ["hyperspy/tests/*"] +omit = [ + "hyperspy/tests/*", + "prepare_release.py", + ] [tool.coverage.report] precision = 2 @@ -120,3 +125,46 @@ include = ["exspy*"] # Presence enables setuptools_scm, the version will be determine at build time from git # The version will be updated by the `prepare_release.py` script fallback_version = "0.1.dev0" + + +[tool.towncrier] +package = "exspy" +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/releasing_guide.md b/releasing_guide.md index 2772d8175..2de718f81 100644 --- a/releasing_guide.md +++ b/releasing_guide.md @@ -4,10 +4,10 @@ To publish a new exSpy release do the following steps: ## Preparation -- Create a new PR to the 'main' branch for the release process, e.g. `release_v0.1.1` with - the following changes: - - Update and check release notes - - Update dev `fallback_version` in `pyproject.toml` +- In a pull request, prepare the release by running the `prepare_release.py` python script (e.g. `python prepare_release.py 0.2`) , which will do the following: + - update the release notes in `CHANGES.rst` by running `towncrier`, + - update the `setuptools_scm` fallback version in `pyproject.toml` (for a patch release, this will stay the same). +- Check release notes - Let that PR collect comments for a day to ensure that other maintainers are comfortable with releasing - Set correct date and version number in `CHANGES.rst`