ci: add rolling Gitea release workflow and release publisher
Rolling Release / Build & Publish Rolling Release (push) Canceled after 0s
Rolling Release / Build & Publish Rolling Release (push) Canceled after 0s
This commit is contained in:
1 parent
7139a64544
commit
80c16ad6ad
5 files changed
+477
-33
No files matched your search
@@ -15,6 +15,8 @@ import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
@@ -48,14 +50,35 @@ def download_cached(url: str, dest: Path, min_bytes: int = 100_000) -> Path:
|
||||
print(f"[build_appimage] Using cached {dest} ({dest.stat().st_size} bytes)")
|
||||
return dest
|
||||
tmp = dest.with_suffix(dest.suffix + ".part")
|
||||
print(f"[build_appimage] Downloading {url} -> {dest}")
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "moon-i2p-appimage-builder/1.0"})
|
||||
with urllib.request.urlopen(req, timeout=180) as resp, open(tmp, "wb") as fp:
|
||||
shutil.copyfileobj(resp, fp, length=1024 * 256)
|
||||
if tmp.stat().st_size < min_bytes:
|
||||
raise RuntimeError(f"Downloaded file too small: {tmp} ({tmp.stat().st_size} bytes)")
|
||||
tmp.replace(dest)
|
||||
return dest
|
||||
max_attempts = 3
|
||||
last_err = None
|
||||
for attempt in range(1, max_attempts + 1):
|
||||
try:
|
||||
print(
|
||||
f"[build_appimage] Downloading {url} -> {dest} (attempt {attempt}/{max_attempts})"
|
||||
)
|
||||
req = urllib.request.Request(
|
||||
url, headers={"User-Agent": "moon-i2p-appimage-builder/1.0"}
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=180) as resp, open(tmp, "wb") as fp:
|
||||
shutil.copyfileobj(resp, fp, length=1024 * 256)
|
||||
if tmp.stat().st_size < min_bytes:
|
||||
raise RuntimeError(
|
||||
f"Downloaded file too small: {tmp} ({tmp.stat().st_size} bytes)"
|
||||
)
|
||||
tmp.replace(dest)
|
||||
return dest
|
||||
except (urllib.error.URLError, OSError, RuntimeError) as exc:
|
||||
last_err = exc
|
||||
if tmp.exists():
|
||||
tmp.unlink(missing_ok=True)
|
||||
if attempt < max_attempts:
|
||||
delay = attempt * 2
|
||||
print(
|
||||
f"[build_appimage] Download attempt {attempt} failed ({exc}); retrying in {delay}s..."
|
||||
)
|
||||
time.sleep(delay)
|
||||
raise RuntimeError(f"Failed downloading {url} after {max_attempts} attempts: {last_err}")
|
||||
|
||||
|
||||
def build_router_binary() -> Path:
|
||||
|
||||
Reference in new issue
Block a user