Added shortcuts for building latest tag
This commit is contained in:
parent
f0722cf631
commit
6d3945b516
37
build.py
37
build.py
@ -176,12 +176,20 @@ class NoServerException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def build_version(manifest: VersionManifest, version_id: str, repository: str = "hub.cnml.de/minecraft"):
|
||||
matching_version = list(
|
||||
filter(lambda v: v["id"] == version_id, manifest["versions"]))
|
||||
if len(matching_version) == 0:
|
||||
raise Exception(f"Version {version_id} not found in manifest!")
|
||||
version = load_version_manifest(matching_version[0])
|
||||
def select_version(manifest: VersionManifest, version_id: str) -> Version:
|
||||
match version_id:
|
||||
case "latest":
|
||||
return select_version(manifest, manifest["latest"]["release"])
|
||||
case "snapshot":
|
||||
return select_version(manifest, manifest["latest"]["snapshot"])
|
||||
case _:
|
||||
matching_version = next(filter(lambda v: v["id"] == version_id, manifest["versions"]), None)
|
||||
if matching_version is None:
|
||||
raise Exception(f"Version {version_id} not found in manifest!")
|
||||
return matching_version
|
||||
|
||||
def build_version(manifest: VersionManifest, version_name: str, repository: str = "hub.cnml.de/minecraft"):
|
||||
version = load_version_manifest(select_version(manifest, version_name))
|
||||
java_version = version.get("javaVersion", default_java_version)
|
||||
print(
|
||||
f"Version [{version['type']}] {version['id']} requires java version {java_version['majorVersion']} ({java_version['component']})")
|
||||
@ -200,17 +208,17 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
|
||||
}
|
||||
|
||||
print(
|
||||
f"Building version {version['id']} (Java {java_version['majorVersion']})")
|
||||
f"Building version {version['id']} (Java {java_version['majorVersion']}) as {version_name}")
|
||||
|
||||
print("# Build GraalVM images")
|
||||
if java_version['majorVersion'] == 17:
|
||||
graal_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
||||
build_args["DOCKER_IMAGE"] = f"ghcr.io/graalvm/jdk:java{java_version['majorVersion']}"
|
||||
docker_buildx(repository, [
|
||||
f"{version['id']}-graalvm"], graal_platforms, build_args=build_args)
|
||||
f"{version_name}-graalvm"], graal_platforms, build_args=build_args)
|
||||
else:
|
||||
print(
|
||||
f"No GraalVM image can be built for {version['id']} (Java {java_version['majorVersion']})")
|
||||
f"No GraalVM image can be built for {version['id']} (Java {java_version['majorVersion']}) as {version_name}")
|
||||
|
||||
print("# Build Temurin images")
|
||||
if java_version['majorVersion'] != 16:
|
||||
@ -218,16 +226,16 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
|
||||
temurin_platforms: list[DockerPlatforms] = [
|
||||
"linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]
|
||||
docker_buildx(
|
||||
repository, [f"{version['id']}-temurin"], temurin_platforms, build_args=build_args)
|
||||
repository, [f"{version_name}-temurin"], temurin_platforms, build_args=build_args)
|
||||
else:
|
||||
print(
|
||||
f"No Temurin image can be built for {version['id']} (Java {java_version['majorVersion']})")
|
||||
f"No Temurin image can be built for {version['id']} (Java {java_version['majorVersion']}) as {version_name}")
|
||||
|
||||
print("# Build Zulu images")
|
||||
build_args["DOCKER_IMAGE"] = f"azul/zulu-openjdk:{java_version['majorVersion']}-jre"
|
||||
zulu_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
||||
docker_buildx(
|
||||
repository, [version["id"], f"{version['id']}-zulu"], zulu_platforms, build_args=build_args)
|
||||
repository, [version_name, f"{version_name}-zulu"], zulu_platforms, build_args=build_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -243,8 +251,9 @@ if __name__ == "__main__":
|
||||
help="Force continue on single version build failure.")
|
||||
args = parser.parse_args()
|
||||
manifest = load_manifest(args.reload)
|
||||
versions: list[str] = list(version["id"] for version in manifest["versions"]
|
||||
if version["type"] == "release") if args.all else args.versions
|
||||
all_versions = list(version["id"] for version in manifest["versions"] if version["type"] == "release")
|
||||
all_versions.append("latest")
|
||||
versions: list[str] = all_versions if args.all else args.versions
|
||||
|
||||
errors: list[tuple[str, Exception]] = []
|
||||
for version_id in versions:
|
||||
|
Loading…
Reference in New Issue
Block a user