Skip to content

Commit 913fa35

Browse files
committed
feat: Added automatic README.md updater for supported Python versions
1 parent d6cb29e commit 913fa35

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Update README with supported versions
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 6 * * 1' # Weekly on Monday at 6 AM UTC (after main builds)
7+
workflow_run:
8+
workflows: ["platforms-dispatches"]
9+
types: [completed]
10+
branches: [main]
11+
12+
jobs:
13+
update-readme:
14+
name: Update README with current supported versions
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.11'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install requests python-dateutil
32+
33+
- name: Generate supported versions
34+
id: generate
35+
run: |
36+
python supported_versions.py ${{ secrets.IDF_VERSIONS_TXT }}
37+
# Capture the supported Python versions for PR description
38+
PYTHON_VERSIONS=$(jq -c '.supported_python' supported_versions.json)
39+
echo "supported_python=$PYTHON_VERSIONS" >> $GITHUB_OUTPUT
40+
41+
- name: Update README with supported Python versions
42+
run: |
43+
python update_readme_versions.py
44+
45+
- name: Check for changes
46+
id: changes
47+
run: |
48+
if git diff --quiet README.md; then
49+
echo "has_changes=false" >> $GITHUB_OUTPUT
50+
echo "No changes detected in README.md"
51+
else
52+
echo "has_changes=true" >> $GITHUB_OUTPUT
53+
echo "Changes detected in README.md"
54+
git diff README.md
55+
fi
56+
57+
- name: Create Pull Request
58+
if: steps.changes.outputs.has_changes == 'true'
59+
uses: peter-evans/create-pull-request@v6
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
commit-message: |
63+
Update README with current supported Python versions
64+
65+
Auto-updated by update-readme workflow based on current ESP-IDF and Python support lifecycle.
66+
67+
Changes:
68+
- Updated supported Python versions in README.md based on dynamic version detection
69+
- Python versions are determined by ESP-IDF lifecycle and Python EOL dates
70+
title: "📝 Update README with current supported Python versions"
71+
body: |
72+
## Summary
73+
This PR automatically updates the README.md with the current supported Python versions based on our dynamic version detection system.
74+
75+
## Changes Made
76+
- ✅ Updated "Supported Python versions" section in README.md
77+
- 🔄 Based on ESP-IDF lifecycle and Python EOL dates
78+
- 🤖 Generated by automated workflow
79+
80+
## Python Versions Updated
81+
The following Python versions are currently supported:
82+
```
83+
${{ steps.generate.outputs.supported_python }}
84+
```
85+
86+
## Verification
87+
- [ ] Python versions match our build matrix
88+
- [ ] No other sections of README were modified
89+
- [ ] All supported versions are actively maintained
90+
91+
---
92+
93+
> **Note**: This PR was automatically created by the [update-readme workflow](.github/workflows/update-readme.yml).
94+
> The Python versions are dynamically determined based on ESP-IDF support lifecycle.
95+
branch: update/readme-python-versions
96+
delete-branch: true
97+
assignees: ${{ github.actor }}
98+
reviewers: jakub-kocka
99+
labels: |
100+
documentation
101+
automated
102+
python-versions

update_readme_versions.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""
4+
Script to update README.md with dynamically detected supported Python versions.
5+
"""
6+
import json
7+
import re
8+
import sys
9+
10+
def update_readme_python_versions():
11+
"""Update the Python versions section in README.md based on supported_versions.json"""
12+
13+
try:
14+
with open('supported_versions.json', 'r') as f:
15+
versions_data = json.load(f)
16+
except FileNotFoundError:
17+
sys.exit('Error: supported_versions.json not found. Run supported_versions.py first.')
18+
19+
supported_python = versions_data.get('supported_python', [])
20+
if not supported_python:
21+
sys.exit('Error: No supported Python versions found in JSON.')
22+
23+
try:
24+
with open('README.md', 'r') as f:
25+
readme_content = f.read()
26+
except FileNotFoundError:
27+
sys.exit('Error: README.md not found.')
28+
29+
new_python_section = []
30+
for version in supported_python:
31+
new_python_section.append(f'* {version}')
32+
new_python_lines = '\n'.join(new_python_section)
33+
34+
# Use regex to find and replace the Python versions section
35+
# Pattern: "Supported Python versions:" followed by lines starting with "* " until next section
36+
pattern = r'(Supported Python versions:\n)((?:\* \d+\.\d+\n)*)'
37+
replacement = f'\\1{new_python_lines}\n'
38+
39+
new_readme = re.sub(pattern, replacement, readme_content)
40+
41+
if new_readme == readme_content:
42+
print('ℹ️ No changes needed - Python versions are already up to date.')
43+
return False
44+
45+
with open('README.md', 'w') as f:
46+
f.write(new_readme)
47+
48+
print(f"✅ Updated README.md with supported Python versions: {', '.join(supported_python)}")
49+
return True
50+
51+
52+
update_readme_python_versions()

0 commit comments

Comments
 (0)