feat: bootstrap static musl build pipeline for iperf3
iperf3 static musl build / build-and-release (push) Failing after 16s
iperf3 static musl build / build-and-release (push) Failing after 16s
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
VERSION_FILE = Path("versions/iperf3.version")
|
||||
LATEST_RELEASE_URL = "https://api.github.com/repos/esnet/iperf/releases/latest"
|
||||
|
||||
|
||||
def fetch_latest_version() -> str:
|
||||
req = urllib.request.Request(
|
||||
LATEST_RELEASE_URL,
|
||||
headers={
|
||||
"Accept": "application/vnd.github+json",
|
||||
"User-Agent": "static-musl-builds-updater",
|
||||
},
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
data = json.load(resp)
|
||||
tag = data["tag_name"].strip()
|
||||
version = re.sub(r"^v", "", tag)
|
||||
if not re.fullmatch(r"[0-9]+(?:\.[0-9]+)*", version):
|
||||
raise ValueError(f"Unexpected iperf3 version format: {version!r}")
|
||||
return version
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--update-file", action="store_true", help="Write latest version into versions/iperf3.version if changed")
|
||||
args = parser.parse_args()
|
||||
|
||||
latest = fetch_latest_version()
|
||||
current = VERSION_FILE.read_text(encoding="utf-8").strip() if VERSION_FILE.exists() else ""
|
||||
|
||||
print(f"current={current or '<missing>'}")
|
||||
print(f"latest={latest}")
|
||||
|
||||
if current == latest:
|
||||
print("status=up-to-date")
|
||||
return 0
|
||||
|
||||
print("status=update-available")
|
||||
if args.update_file:
|
||||
VERSION_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
VERSION_FILE.write_text(latest + "\n", encoding="utf-8")
|
||||
print(f"updated_file={VERSION_FILE}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user