|
96 | 96 | debian="bookworm" |
97 | 97 | fi |
98 | 98 |
|
99 | | - # Update the line in the table |
100 | | - sed -i "s/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` |/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` (${version}) |/g" README.md |
| 99 | + # Check if this is the latest Python version (has ":latest" tag) |
| 100 | + # Currently 3.14, but will be 3.15, 3.16, etc. in the future |
| 101 | + if grep -q "| ${minor} | \`:${minor}\` or \`:latest\` |" README.md; then |
| 102 | + # Handle version with :latest tag |
| 103 | + # First try to update existing version |
| 104 | + sed -i "s/| ${minor} | \`:${minor}\` or \`:latest\` | \`python:${minor}-slim-${debian}\` ([^)]*) |/| ${minor} | \`:${minor}\` or \`:latest\` | \`python:${minor}-slim-${debian}\` (${version}) |/g" README.md |
| 105 | + # If no existing version, add it |
| 106 | + sed -i "s/| ${minor} | \`:${minor}\` or \`:latest\` | \`python:${minor}-slim-${debian}\` |/| ${minor} | \`:${minor}\` or \`:latest\` | \`python:${minor}-slim-${debian}\` (${version}) |/g" README.md |
| 107 | + else |
| 108 | + # Handle regular version without :latest tag |
| 109 | + # First try to update existing version |
| 110 | + sed -i "s/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` ([^)]*) |/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` (${version}) |/g" README.md |
| 111 | + # If no existing version, add it |
| 112 | + sed -i "s/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` |/| ${minor} | \`:${minor}\` | \`python:${minor}-slim-${debian}\` (${version}) |/g" README.md |
| 113 | + fi |
101 | 114 | done |
102 | 115 |
|
103 | 116 | # Check if there were changes |
@@ -139,6 +152,35 @@ jobs: |
139 | 152 |
|
140 | 153 | echo "Workflow updated to include Python ${NEW_VERSION}" |
141 | 154 |
|
| 155 | + # Update README table to add new minor version |
| 156 | + echo "Adding Python ${NEW_VERSION} to README table..." |
| 157 | +
|
| 158 | + # Find the current "latest" version line (currently 3.14) |
| 159 | + CURRENT_LATEST=$(grep -E "\\| [0-9.]+ \\| \`:[0-9.]+\` or \`:latest\`" README.md | sed -E 's/.*\| ([0-9.]+) \| .*/\1/' | head -1) |
| 160 | +
|
| 161 | + if [ -n "$CURRENT_LATEST" ]; then |
| 162 | + echo "Current latest version: ${CURRENT_LATEST}" |
| 163 | +
|
| 164 | + # Remove ":latest" tag from current latest version |
| 165 | + sed -i "s/| ${CURRENT_LATEST} | \`:${CURRENT_LATEST}\` or \`:latest\` |/| ${CURRENT_LATEST} | \`:${CURRENT_LATEST}\` |/g" README.md |
| 166 | +
|
| 167 | + # Get the distroless version for the current latest (to use as template) |
| 168 | + DISTROLESS=$(grep "| ${CURRENT_LATEST} |" README.md | sed -E 's/.*gcr.io\/distroless\/(python3-debian[0-9]+).*/\1/' | head -1) |
| 169 | + DISTROLESS="gcr.io/distroless/${DISTROLESS}" |
| 170 | +
|
| 171 | + # Add new row after current latest with :latest tag |
| 172 | + # The new version will use bookworm (Debian 12) as it's a recent Python version |
| 173 | + NEW_ROW="| ${NEW_VERSION} | \`:${NEW_VERSION}\` or \`:latest\` | \`python:${NEW_VERSION}-slim-bookworm\` (${VERSION}) | \`debian:bookworm-slim\` | \`${DISTROLESS}\` |" |
| 174 | +
|
| 175 | + # Insert new row after the previous latest (GNU sed syntax) |
| 176 | + sed -i "/| ${CURRENT_LATEST} |/a\\${NEW_ROW}" README.md |
| 177 | +
|
| 178 | + echo "Added new row for Python ${NEW_VERSION} with :latest tag" |
| 179 | + echo "Removed :latest tag from Python ${CURRENT_LATEST}" |
| 180 | + else |
| 181 | + echo "Warning: Could not find current latest version in README" |
| 182 | + fi |
| 183 | +
|
142 | 184 | - name: Create Pull Request |
143 | 185 | if: steps.update-readme.outputs.changes_detected == 'true' || steps.check.outputs.new_minor_version |
144 | 186 | uses: peter-evans/create-pull-request@v7 |
|
0 commit comments