From 3a89bb9b387a668985d79a438c739f62ffb42bf9 Mon Sep 17 00:00:00 2001 From: Mike Edmunds Date: Mon, 4 Dec 2023 11:33:44 -0800 Subject: [PATCH] Packaging: fix status badges in frozen readme GitHub status badge urls no longer allow branch=TAG. Must use branch=BRANCH or tag=TAG. (This was only visible in published description on PyPI.) (Actions job filter still requires branch=TAG_OR_BRANCH) --- hatch_build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hatch_build.py b/hatch_build.py index fe06808..6a8e8ff 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -12,10 +12,16 @@ def freeze_readme_versions(text: str, version: str) -> str: (This assumes version X.Y will be tagged "vX.Y" in git.) """ release_tag = f"v{version}" + # (?<=...) is "positive lookbehind": must be there, but won't get replaced + text = re.sub( + # GitHub Actions badge: badge.svg?branch=main --> badge.svg?tag=vX.Y.Z: + r"(?<=badge\.svg\?)branch=main", + f"tag={release_tag}", + text, + ) return re.sub( - # (?<=...) is "positive lookbehind": must be there, but won't get replaced - # GitHub Actions build status: branch=main --> branch=vX.Y.Z: - r"(?<=branch[=:])main" + # GitHub Actions status links: branch:main --> branch:vX.Y.Z: + r"(?<=branch:)main" # ReadTheDocs links: /stable --> /vX.Y.Z: r"|(?<=/)stable" # ReadTheDocs badge: version=stable --> version=vX.Y.Z: