Skip to main content

Build a sphinx changelog from GitHub Releases

Project description

Sphinx Github Changelog: Build a sphinx changelog from GitHub Releases

Deployed to PyPI Documentation Status Continuous Integration Status Coverage Status MIT License Contributor Covenant

Sphinx-github-changelog is a Sphinx plugin that builds a changelog section based on a repository’s GitHub Releases content.

How ? (the short version)

In your Sphinx documentation conf.py:

extensions = [
    ...,  # your other extensions
    "sphinx_github_changelog",
]

# Provide a GitHub API token:
# Pass the SPHINX_GITHUB_CHANGELOG_TOKEN environment variable to your build
# OR
sphinx_github_changelog_token = "..."

In your documentation:

.. changelog::
    :changelog-url: https://your-project.readthedocs.io/en/stable/changelog.html
    :github: https://github.com/you/your-project/releases/
    :pypi: https://pypi.org/project/your-project/

See the end result for this project on ReadTheDocs.

Why ?

On the way to continuous delivery, it’s important to be able to release easily. One of the criteria for easy releases is that the release doesn’t require a commit and a Pull Request. Release Pull Requests usually include 2 parts:

  • Changing the version

  • Updating the changelog (if you keep a changelog, let’s assume you do)

Commitless releases need a way to store the version and the changelog, as close as possible to the code, but actually not in the code.

Setting aside the “version” question, sphinx-github-changelog aims at providing a good way of managing the “changelog” part:

The best solution we’ve found so far for the changelog is to store it in the body of GitHub Releases. That’s very practical for maintainers, but it may not be the first place people will look for it. As far as we’ve seen, people expect the changelog to be:

  • in the repo, in CHANGELOG.rst,

  • in the documentation.

Having the changelog in CHANGELOG.rst causes a few problems:

  • Either each PR adds its single line of changelog, but:

    • you’ll most probably run into countless merge conflicts,

    • the changelog won’t tell you which contribution was part of which release

    This reduces the interest for the whole thing.

  • Or your changelog is edited at release time. Maybe you’re using towncrier for fragment-based changelog, but you’re not doing commitless releases anymore. You could imagine that the release commit is done by your CI, but this can quickly become annoying, especially if you require Pull Requests.

But there is another way. Instead of providing the changelog, the CHANGELOG.rst file can hold a link to the changelog. This makes things much easier. sphinx-github-changelog encourages you to do that.

A complete toolbelt

Alongside sphinx-github-changelog, we suggest a few tools that play nice together:

  • setuptools-scm will compute your version in setup.py based on git tags.

  • release-drafter will keep a “Draft release” updated as you merge Pull Requests to your repository, so you just have to slightly adjust the release body, and create a tag.

  • Any Continuous Integration solution should be able to listen to new tags, and build and upload distributions to PyPI. Don’t forget to use PyPI API tokens!

  • And ReadTheDocs to host your built documentation, of course.

If you’re using all the tools above, then releasing is simple as proof-reading the draft GitHub Release and press “Publish Release”. That’s it.

Reference documentation

Extension options (conf.py)

  • changelog_github_token: GitHub API token, with read access to the repository. Defaults to the value of the environment variable SPHINX_GITHUB_CHANGELOG_TOKEN. If no value is provided, the build will still pass but the changelog will not be built, and a link to the changelog-url will be displayed (if provided).

Directive

.. changelog::
    :changelog-url: https://your-project.readthedocs.io/en/stable/changelog.html
    :github: https://github.com/you/your-project/releases/
    :pypi: https://pypi.org/project/your-project/

Attributes

  • github (required): URL to the releases page of the repository.

  • changelog-url (optional): URL to the built version of your changelog. sphinx-github-changelog will display a link to your built changelog if the GitHub token is not provided (hopefully, this does not happen in your built documentation)

  • pypi (optional): URL to the PyPI page of the repository. This allows the changelog to display links to each PyPI release.

You’ll notice that each parameter here is not requested in the simplest form but as very specific URLs from which the program extracts the needed information. This is done on purpose. If people browse the unbuilt version of your documentation (e.g. on GitHub or PyPI directly), they’ll still be presented with links to the pages that contain the information they will need, instead of unhelping directives.

Check out the built version!

This Readme is also built as a Sphinx documentation, and it includes the changelog. Interested to see how it looks ? Check it out on our ReadTheDocs space.

If you encounter a bug, or want to get in touch, you’re always welcome to open a ticket.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-github-changelog-1.0.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_github_changelog-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file sphinx-github-changelog-1.0.0.tar.gz.

File metadata

  • Download URL: sphinx-github-changelog-1.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for sphinx-github-changelog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 461653ed48a68ba9658e646c147f9377ca327cc3b5be8f3660a9d9d73e7b028a
MD5 6b93a21b8002a3984d3e63db4f0d5691
BLAKE2b-256 87538bf87246381ee5d2ad59a820e7d9e273f3dd5b73b716b257ba6df2a65464

See more details on using hashes here.

File details

Details for the file sphinx_github_changelog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sphinx_github_changelog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for sphinx_github_changelog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0fc495821a388346a9dd6e8a19d5d3728471031fad419c74c5466f8d57f220b
MD5 ff59b4c84e1db948682ceda345be2f2a
BLAKE2b-256 2bb64633901c878b31a2c0cabaf06f16dcad6962ea3ae1e86fa683a61f26dc2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page