Skip to content

Instantly share code, notes, and snippets.

@sarnold
Created June 14, 2025 22:44
Show Gist options
  • Save sarnold/0772041c7ba71dc9fda01affc8cd1429 to your computer and use it in GitHub Desktop.
Save sarnold/0772041c7ba71dc9fda01affc8cd1429 to your computer and use it in GitHub Desktop.
get last git tag from inside sphinx conf.py
import subprocess as sp
from shlex import split
def get_last_tag():
"""
Get the last tag value from git.
"""
git_tag_str = "git describe --abbrev=0 --tags"
return sp.check_output(split(git_tag_str), text=True).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment