Skip to content

Commit 483b1d5

Browse files
committed
update relative image paths in README at package to the correct url
1 parent 33977b5 commit 483b1d5

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.github/workflows/build-test-package-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ jobs:
187187
- name: install node modules
188188
run: npm install --also=dev
189189

190+
- name: update doc links
191+
if: startsWith( github.ref, 'refs/tags/v')
192+
run: poetry run npm run update-doc-links
193+
190194
- name: package
191195
run: poetry run npm run package
192196

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@
649649
"package": "python scripts/package.py",
650650
"publish": "python scripts/publish.py",
651651
"package-publish": "npm run package && python scripts/publish.py",
652-
"extract-release-notes": "python scripts/extract_release_notes.py"
652+
"extract-release-notes": "python scripts/extract_release_notes.py",
653+
"update-doc-links": "python scripts/update_doc_links.py"
653654
},
654655
"extensionDependencies": [
655656
"ms-python.python"

scripts/update_doc_links.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import re
2+
from pathlib import Path
3+
4+
5+
from scripts.tools import get_version
6+
7+
8+
def replace_in_file(filename: Path, pattern: "re.Pattern[str]", to: str) -> None:
9+
text = filename.read_text()
10+
11+
new = pattern.sub(to, text)
12+
filename.write_text(new)
13+
14+
15+
REPOSITORY_BASE = "https://raw.githubusercontent.com/d-biehl/robotcode"
16+
17+
18+
def main() -> None:
19+
20+
version = get_version()
21+
22+
tag_base = f"{REPOSITORY_BASE}/v{version}"
23+
24+
replace_in_file(
25+
Path("README.md"),
26+
re.compile(r"(\!\[.*?\]\()(\.)(/[^\)]*?)(\))"),
27+
rf"""\g<1>{tag_base}\g<3>\g<4>""",
28+
)
29+
30+
31+
if __name__ == "__main__":
32+
main()

0 commit comments

Comments
 (0)