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
|
pass
|
||||||
|
|
||||||
|
|
||||||
def build_version(manifest: VersionManifest, version_id: str, repository: str = "hub.cnml.de/minecraft"):
|
def select_version(manifest: VersionManifest, version_id: str) -> Version:
|
||||||
matching_version = list(
|
match version_id:
|
||||||
filter(lambda v: v["id"] == version_id, manifest["versions"]))
|
case "latest":
|
||||||
if len(matching_version) == 0:
|
return select_version(manifest, manifest["latest"]["release"])
|
||||||
raise Exception(f"Version {version_id} not found in manifest!")
|
case "snapshot":
|
||||||
version = load_version_manifest(matching_version[0])
|
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)
|
java_version = version.get("javaVersion", default_java_version)
|
||||||
print(
|
print(
|
||||||
f"Version [{version['type']}] {version['id']} requires java version {java_version['majorVersion']} ({java_version['component']})")
|
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(
|
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")
|
print("# Build GraalVM images")
|
||||||
if java_version['majorVersion'] == 17:
|
if java_version['majorVersion'] == 17:
|
||||||
graal_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
graal_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
||||||
build_args["DOCKER_IMAGE"] = f"ghcr.io/graalvm/jdk:java{java_version['majorVersion']}"
|
build_args["DOCKER_IMAGE"] = f"ghcr.io/graalvm/jdk:java{java_version['majorVersion']}"
|
||||||
docker_buildx(repository, [
|
docker_buildx(repository, [
|
||||||
f"{version['id']}-graalvm"], graal_platforms, build_args=build_args)
|
f"{version_name}-graalvm"], graal_platforms, build_args=build_args)
|
||||||
else:
|
else:
|
||||||
print(
|
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")
|
print("# Build Temurin images")
|
||||||
if java_version['majorVersion'] != 16:
|
if java_version['majorVersion'] != 16:
|
||||||
@ -218,16 +226,16 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
|
|||||||
temurin_platforms: list[DockerPlatforms] = [
|
temurin_platforms: list[DockerPlatforms] = [
|
||||||
"linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]
|
"linux/arm64", "linux/arm/v7", "linux/amd64", "linux/ppc64le"]
|
||||||
docker_buildx(
|
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:
|
else:
|
||||||
print(
|
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")
|
print("# Build Zulu images")
|
||||||
build_args["DOCKER_IMAGE"] = f"azul/zulu-openjdk:{java_version['majorVersion']}-jre"
|
build_args["DOCKER_IMAGE"] = f"azul/zulu-openjdk:{java_version['majorVersion']}-jre"
|
||||||
zulu_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
zulu_platforms: list[DockerPlatforms] = ["linux/arm64", "linux/amd64"]
|
||||||
docker_buildx(
|
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__":
|
if __name__ == "__main__":
|
||||||
@ -243,8 +251,9 @@ if __name__ == "__main__":
|
|||||||
help="Force continue on single version build failure.")
|
help="Force continue on single version build failure.")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
manifest = load_manifest(args.reload)
|
manifest = load_manifest(args.reload)
|
||||||
versions: list[str] = list(version["id"] for version in manifest["versions"]
|
all_versions = list(version["id"] for version in manifest["versions"] if version["type"] == "release")
|
||||||
if version["type"] == "release") if args.all else args.versions
|
all_versions.append("latest")
|
||||||
|
versions: list[str] = all_versions if args.all else args.versions
|
||||||
|
|
||||||
errors: list[tuple[str, Exception]] = []
|
errors: list[tuple[str, Exception]] = []
|
||||||
for version_id in versions:
|
for version_id in versions:
|
||||||
|
Loading…
Reference in New Issue
Block a user