minor release note addition #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Normalize README images | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - README.md | |
| - "docs/**" | |
| - "**/*.png" | |
| - "**/*.jpg" | |
| - "**/*.jpeg" | |
| - "**/*.gif" | |
| - "**/*.svg" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: readme-normalize-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| fix: | |
| if: github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Rewrite relative image links in README.md | |
| run: | | |
| python - <<'PY' | |
| import os, re, pathlib | |
| base = f"https://raw.githubusercontent.com/{os.environ['GITHUB_REPOSITORY']}/HEAD/" | |
| p = pathlib.Path("README.md") | |
| if not p.exists(): | |
| print("README.md not found, skipping") | |
| exit(0) | |
| t = p.read_text(encoding="utf-8") | |
| # Handle Markdown image syntax  | |
| t2 = re.sub(r'(!\[[^\]]*\]\()((?!https?://)[^)]+)(\))', | |
| lambda m: m.group(1) + base + m.group(2).lstrip("./") + m.group(3), t) | |
| # Handle HTML img tags <img src="url"> | |
| t2 = re.sub(r'(<img\s+[^>]*src=")([^"]+)("[^>]*>)', | |
| lambda m: m.group(1) + (base + m.group(2).lstrip("./") if not m.group(2).startswith(('http://', 'https://')) else m.group(2)) + m.group(3), t2) | |
| if t2 != t: | |
| p.write_text(t2, encoding="utf-8") | |
| print(f"Updated README.md with normalized image links") | |
| else: | |
| print("README.md already has normalized image links") | |
| PY | |
| - name: Commit if changed | |
| run: | | |
| git config user.name "pypi readme workflow" | |
| git add README.md | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "docs(readme): normalize image links [skip ci]" | |
| git push | |
| echo "Committed and pushed normalized README" | |
| fi |