Skip to content

Commit 804e16d

Browse files
authored
ci: use ubuntu latest (#140)
1 parent be0f52b commit 804e16d

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

scripts/generate_version_matrix.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,28 @@
22
import json
33
import re
44

5+
56
def get_git_tags():
67
try:
78
result = subprocess.run(
8-
["git", "tag", "--points-at", "HEAD"], capture_output=True, text=True, check=True
9+
["git", "tag", "--points-at", "HEAD"],
10+
capture_output=True,
11+
text=True,
12+
check=True,
913
)
1014
return result.stdout.strip().splitlines()
1115
except subprocess.CalledProcessError:
1216
# if no tags are found, return an empty list
1317
return []
1418

19+
1520
def extract_name_and_version_from_tag(tag):
1621
match = re.match(r"(pixi-build-[a-zA-Z-]+)-v(\d+\.\d+\.\d+)", tag)
1722
if match:
1823
return match.group(1), match.group(2)
19-
raise ValueError(f"Invalid Git tag format: {tag}. Expected format: pixi-build-[name]-v[version]")
24+
raise ValueError(
25+
f"Invalid Git tag format: {tag}. Expected format: pixi-build-[name]-v[version]"
26+
)
2027

2128

2229
def generate_matrix():
@@ -32,20 +39,20 @@ def generate_matrix():
3239
# this is to overcome the issue of matrix generation from github actions side
3340
# https://github.com/orgs/community/discussions/67591
3441
targets = [
35-
{"target": "linux-64", "os": "ubuntu-20.04"},
42+
{"target": "linux-64", "os": "ubuntu-latest"},
3643
{"target": "linux-aarch64", "os": "ubuntu-latest"},
3744
{"target": "linux-ppc64le", "os": "ubuntu-latest"},
3845
{"target": "win-64", "os": "windows-latest"},
3946
{"target": "osx-64", "os": "macos-13"},
40-
{"target": "osx-arm64", "os": "macos-14"}
47+
{"target": "osx-arm64", "os": "macos-14"},
4148
]
4249

4350
git_tags = get_git_tags()
4451

4552
# Extract bin names, versions, and generate env and recipe names
4653
matrix = []
4754

48-
if not "packages" in metadata:
55+
if "packages" not in metadata:
4956
raise ValueError("No packages found using cargo metadata")
5057

5158
# verify that the tags match the package versions
@@ -62,7 +69,9 @@ def generate_matrix():
6269
continue # Skip packages that do not match the tag
6370

6471
if package["version"] != tag_version:
65-
raise ValueError(f"Version mismatch: Git tag version {tag_version} does not match Cargo version {package["version"]} for {package["name"]}")
72+
raise ValueError(
73+
f"Version mismatch: Git tag version {tag_version} does not match Cargo version {package['version']} for {package['name']}"
74+
)
6675

6776
tagged_packages[git_tag] = package
6877
package_tagged = True
@@ -73,25 +82,29 @@ def generate_matrix():
7382
continue
7483

7584
for target in targets:
76-
matrix.append({
77-
"bin": package["name"],
78-
"version": package["version"],
79-
"env_name": package["name"].replace("-", "_").upper() + "_VERSION",
80-
"crate_name": package["name"],
81-
"target": target["target"],
82-
"os": target["os"]
83-
})
85+
matrix.append(
86+
{
87+
"bin": package["name"],
88+
"version": package["version"],
89+
"env_name": package["name"].replace("-", "_").upper()
90+
+ "_VERSION",
91+
"crate_name": package["name"],
92+
"target": target["target"],
93+
"os": target["os"],
94+
}
95+
)
8496

8597
if tagged_packages:
8698
for git_tag, has_a_package in tagged_packages.items():
8799
if not has_a_package:
88-
raise ValueError(f"Git tag {git_tag} does not match any package in Cargo.toml")
89-
100+
raise ValueError(
101+
f"Git tag {git_tag} does not match any package in Cargo.toml"
102+
)
90103

91104
matrix_json = json.dumps(matrix)
92105

93-
94106
print(matrix_json)
95107

108+
96109
if __name__ == "__main__":
97110
generate_matrix()

0 commit comments

Comments
 (0)