@@ -69,38 +69,59 @@ jobs:
6969 from pathlib import Path
7070
7171 full_version = os.environ["FULL_VERSION"]
72- path = Path("README.md")
73- text = path.read_text(encoding="utf-8")
74- line = f"Latest release: `{full_version}` (auto-updated)"
75-
76- if re.search(r"^Latest release:.*$", text, flags=re.M):
77- text = re.sub(r"^Latest release:.*$", line, text, flags=re.M)
78- else:
79- lines = text.splitlines()
80- if lines:
81- lines.insert(1, "")
82- lines.insert(2, line)
83- text = "\n".join(lines) + "\n"
84- else:
85- text = f"{line}\n"
86-
87- if not text.endswith("\n"):
88- text += "\n"
89-
90- path.write_text(text, encoding="utf-8")
72+ usage_pattern = re.compile(
73+ r"^(?P<prefix>\s*-?\s*uses:\s*ProverCoderAI/action-release@)"
74+ r"v\d+(?:\.\d+){0,2}\b",
75+ flags=re.M,
76+ )
77+
78+ def update_readme(text: str) -> str:
79+ line = f"Latest release: `{full_version}` (auto-updated)"
80+
81+ if re.search(r"^Latest release:.*$", text, flags=re.M):
82+ text = re.sub(r"^Latest release:.*$", line, text, flags=re.M)
83+ else:
84+ lines = text.splitlines()
85+ if lines:
86+ lines.insert(1, "")
87+ lines.insert(2, line)
88+ text = "\n".join(lines) + "\n"
89+ else:
90+ text = f"{line}\n"
91+
92+ text = usage_pattern.sub(rf"\g<prefix>{full_version}", text)
93+
94+ if not text.endswith("\n"):
95+ text += "\n"
96+ return text
97+
98+ def update_usage_examples(text: str) -> str:
99+ text = usage_pattern.sub(rf"\g<prefix>{full_version}", text)
100+ if not text.endswith("\n"):
101+ text += "\n"
102+ return text
103+
104+ readme_path = Path("README.md")
105+ readme_text = readme_path.read_text(encoding="utf-8")
106+ readme_path.write_text(update_readme(readme_text), encoding="utf-8")
107+
108+ setup_path = Path("SETUP.md")
109+ if setup_path.exists():
110+ setup_text = setup_path.read_text(encoding="utf-8")
111+ setup_path.write_text(update_usage_examples(setup_text), encoding="utf-8")
91112 PY
92113
93114 - name : Commit README update
94115 shell : bash
95116 run : |
96117 set -euo pipefail
97- if git diff --quiet README.md; then
98- echo "README is already up to date."
118+ if git diff --quiet README.md SETUP.md ; then
119+ echo "Docs are already up to date."
99120 exit 0
100121 fi
101122
102- git add README.md
103- git commit -m "chore(release): update README for ${FULL_VERSION}"
123+ git add README.md SETUP.md
124+ git commit -m "chore(release): update docs for ${FULL_VERSION}"
104125 git fetch origin main
105126 git rebase origin/main
106127 git push origin "HEAD:main"
0 commit comments