Skip versions without server jar

This commit is contained in:
Michael Chen 2022-11-15 09:29:32 +01:00
parent 8aa106d5bc
commit 3bd942d471
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629

View File

@ -39,10 +39,10 @@ class DownloadInfo(TypedDict):
class VersionDownloads(TypedDict):
client: DownloadInfo
client_mappings: DownloadInfo
server: DownloadInfo
server_mappings: DownloadInfo
client: NotRequired[DownloadInfo]
client_mappings: NotRequired[DownloadInfo]
server: NotRequired[DownloadInfo]
server_mappings: NotRequired[DownloadInfo]
class VersionManifestFull(TypedDict):
@ -152,6 +152,9 @@ default_java_version: JavaVersion = {
"majorVersion": 8
}
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"]))
@ -162,7 +165,10 @@ def build_version(manifest: VersionManifest, version_id: str, repository: str =
print(
f"Version [{version['type']}] {version['id']} requires java version {java_version['majorVersion']} ({java_version['component']})")
server_jar_file = Path("versions") / version['id'] / "server.jar"
server_jar = version["downloads"]["server"]
server_jar = version["downloads"].get("server")
if server_jar is None:
raise NoServerException(f"No server build exists for {version['id']} (Java {java_version['majorVersion']})")
download_file(server_jar, server_jar_file)
build_args: DockerfileBuildArgs = {
@ -204,8 +210,11 @@ if __name__ == "__main__":
versions: list[str] = list(version["id"] for version in manifest["versions"]
if version["type"] == "release") if args.all else args.versions
for version_id in versions:
print()
try:
build_version(manifest, version_id)
except NoServerException as e:
print(e)
except Exception as e:
print(f"Failed building images for version {version_id}")
if args.force: