File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1717import time
1818from importlib .metadata import version
1919from pathlib import Path
20+ import requests
2021
2122# If extensions (or modules to document with autodoc) are in another directory,
2223# add these directories to sys.path here. If the directory is relative to the
6869# |version| and |release|, also used in various other places throughout the
6970# built documents.
7071
72+ def _get_latest_release_from_github (org : str , repo_name : str ) -> str :
73+ """Get the highest version release (including prereleases) from GitHub
74+ repository."""
75+ url = f"https://api.github.com/repos/{ org } /{ repo_name } /releases"
76+ response = requests .get (url )
77+ releases = response .json ()
78+ valid_releases = [release for release in releases if "tag_name" in release ]
79+ if not valid_releases :
80+ return "No valid releases found"
81+ latest_version_release = valid_releases [0 ]["tag_name" ]
82+ return latest_version_release
83+
84+
85+ # Get the latest release version from GitHub repository
86+ org = "diffpy"
87+ repo_name = "diffpy.utils"
88+ latest_verion_from_github = _get_latest_release_from_github (org , repo_name )
89+
7190fullversion = version (project )
7291# The short X.Y version.
7392version = "" .join (fullversion .split (".post" )[:1 ])
7493# The full version, including alpha/beta/rc tags.
75- release = fullversion
94+ release = latest_verion_from_github
7695
7796# The language for content autogenerated by Sphinx. Refer to documentation
7897# for a list of supported languages.
Original file line number Diff line number Diff line change 1+ **Added: **
2+
3+ * <news item>
4+
5+ **Changed: **
6+
7+ * Method to retrieve the latest package version from GitHub's release page in the official documentation. The latest release on GitHub is used to retrieve the latest version of the package instead of a tag.
8+
9+ **Deprecated: **
10+
11+ * <news item>
12+
13+ **Removed: **
14+
15+ * <news item>
16+
17+ **Fixed: **
18+
19+ * <news item>
20+
21+ **Security: **
22+
23+ * <news item>
You can’t perform that action at this time.
0 commit comments