# SPDX-License-Identifier: MIT # Copyright (C) 2026 Bryan Joshua Pedini import json import re import urllib.request from pathlib import Path def fetch(url): request = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json", "User-Agent": "coredns-mysql-updater"}) with urllib.request.urlopen(request, timeout=30) as response: return json.load(response) release = fetch("https://api.github.com/repos/coredns/coredns/releases/latest") plugin = fetch("https://api.github.com/repos/cloud66-oss/coredns_mysql/commits/HEAD") tag = release["tag_name"] revision = plugin["sha"] if not re.fullmatch(r"v[0-9]+\.[0-9]+\.[0-9]+", tag): raise SystemExit(f"Unexpected CoreDNS release: {tag}") if not re.fullmatch(r"[0-9a-f]{40}", revision): raise SystemExit("Unexpected plugin revision") Path("versions.env").write_text(f"COREDNS_VERSION={tag[1:]}\nMYSQL_PLUGIN_REV={revision}\n")