Skip to content

Commit 152115e

Browse files
committed
Add automatic update of spring-versions.json
1 parent 88fc4fb commit 152115e

3 files changed

Lines changed: 154 additions & 9 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import json
2+
import re
3+
from collections import defaultdict
4+
from packaging.version import Version
5+
from xml.etree import ElementTree as ET
6+
import urllib.request
7+
8+
# Configuration
9+
managed_minors = {"3.0", "3.1", "3.2", "3.3", "3.4"}
10+
boot_java_compatibility = {
11+
"3.0": ["17"], # Java 21 not supported
12+
"3.1": ["17", "21"],
13+
"3.2": ["17", "21"],
14+
"3.3": ["17", "21"],
15+
"3.4": ["17", "21"]
16+
}
17+
output_path = ".github/spring-versions.json"
18+
19+
# Step 1: Fetch Spring Boot versions
20+
metadata_url = "https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter/maven-metadata.xml"
21+
with urllib.request.urlopen(metadata_url) as response:
22+
xml_data = response.read()
23+
24+
root = ET.fromstring(xml_data)
25+
versions = [v.text for v in root.findall(".//version")]
26+
27+
boot_versions = defaultdict(list)
28+
for v in versions:
29+
if not re.match(r"^\d+\.\d+\.\d+$", v):
30+
continue
31+
minor = ".".join(v.split(".")[:2])
32+
if minor in managed_minors:
33+
boot_versions[minor].append(Version(v))
34+
35+
latest_boot_versions = {minor: str(max(vlist)) for minor, vlist in boot_versions.items()}
36+
37+
# Step 2: Resolve Spring Framework version
38+
def get_spring_framework_version(boot_version: str) -> str:
39+
pom_url = f"https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter/{boot_version}/spring-boot-starter-{boot_version}.pom"
40+
try:
41+
with urllib.request.urlopen(pom_url) as response:
42+
pom_data = response.read()
43+
pom_root = ET.fromstring(pom_data)
44+
ns = {'m': 'http://maven.apache.org/POM/4.0.0'}
45+
for dep in pom_root.findall(".//m:dependency", ns):
46+
gid = dep.find("m:groupId", ns)
47+
aid = dep.find("m:artifactId", ns)
48+
ver = dep.find("m:version", ns)
49+
if gid is not None and aid is not None and ver is not None:
50+
if gid.text == "org.springframework" and aid.text == "spring-core":
51+
return ver.text
52+
except Exception as e:
53+
print(f"Warning: Failed to fetch framework version for {boot_version}: {e}")
54+
return "unknown"
55+
56+
# Step 3: Build matrix
57+
matrix_entries = []
58+
for minor, boot_version in sorted(latest_boot_versions.items()):
59+
framework_version = get_spring_framework_version(boot_version)
60+
for java_version in boot_java_compatibility.get(minor, []):
61+
matrix_entries.append({
62+
"boot": boot_version,
63+
"framework": framework_version,
64+
"java": str(java_version)
65+
})
66+
67+
# Step 4: Save result
68+
with open(output_path, "w") as f:
69+
json.dump({"matrix": matrix_entries}, f, indent=2)
70+
71+
print(f"Updated {output_path} with {len(matrix_entries)} matrix entries.")

.github/spring-versions.json

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
11
{
22
"matrix": [
3-
{ "boot": "3.0.13", "framework": "6.0.14", "java": "17" },
4-
{ "boot": "3.1.12", "framework": "6.0.21", "java": "17" },
5-
{ "boot": "3.1.12", "framework": "6.0.21", "java": "21" },
6-
{ "boot": "3.2.12", "framework": "6.1.15", "java": "17" },
7-
{ "boot": "3.2.12", "framework": "6.1.15", "java": "21" },
8-
{ "boot": "3.3.12", "framework": "6.1.20", "java": "17" },
9-
{ "boot": "3.3.12", "framework": "6.1.20", "java": "21" },
10-
{ "boot": "3.4.6", "framework": "6.2.7", "java": "17" },
11-
{ "boot": "3.4.6", "framework": "6.2.7", "java": "21" }
3+
{
4+
"boot": "3.0.13",
5+
"framework": "6.0.14",
6+
"java": "17"
7+
},
8+
{
9+
"boot": "3.1.11",
10+
"framework": "6.0.20",
11+
"java": "17"
12+
},
13+
{
14+
"boot": "3.1.12",
15+
"framework": "6.0.21",
16+
"java": "21"
17+
},
18+
{
19+
"boot": "3.2.12",
20+
"framework": "6.1.15",
21+
"java": "17"
22+
},
23+
{
24+
"boot": "3.2.12",
25+
"framework": "6.1.15",
26+
"java": "21"
27+
},
28+
{
29+
"boot": "3.3.12",
30+
"framework": "6.1.20",
31+
"java": "17"
32+
},
33+
{
34+
"boot": "3.3.12",
35+
"framework": "6.1.20",
36+
"java": "21"
37+
},
38+
{
39+
"boot": "3.4.6",
40+
"framework": "6.2.7",
41+
"java": "17"
42+
},
43+
{
44+
"boot": "3.4.6",
45+
"framework": "6.2.7",
46+
"java": "21"
47+
}
1248
]
1349
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update Spring Versions Matrix
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 1 * *' # Monthly on the 1st at 03:00 UTC
6+
workflow_dispatch: # Allow manual trigger as well
7+
8+
jobs:
9+
update-matrix:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Install Python dependencies
22+
run: pip install packaging
23+
24+
- name: Run update script
25+
run: python .github/scripts/update-spring-versions.py
26+
27+
- name: Create Pull Request
28+
uses: peter-evans/create-pull-request@v6
29+
with:
30+
commit-message: "chore: update Spring Boot/Framework testing matrix"
31+
title: "Update Spring Versions Matrix"
32+
body: |
33+
This PR updates the `spring-versions.json` matrix with the latest patch versions of Spring Boot and their corresponding Spring Framework versions for Java 17 and 21.
34+
branch: update/spring-versions-matrix
35+
labels: |
36+
dependencies
37+
spring
38+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

0 commit comments

Comments
 (0)