|
|
|
@@ -1121,14 +1121,14 @@ async def get_version():
|
|
|
|
|
|
|
|
|
|
@app.get("/check_update")
|
|
|
|
|
async def check_update():
|
|
|
|
|
"""Check for available updates by comparing current version with latest release tag."""
|
|
|
|
|
"""Check for available updates by comparing current version with latest tag on main branch."""
|
|
|
|
|
try:
|
|
|
|
|
# server -> auracast -> src -> bumble-auracast (3 levels up)
|
|
|
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
|
|
|
|
|
|
|
|
|
# Fetch all tags and refs from origin
|
|
|
|
|
# Fetch tags and main branch from origin
|
|
|
|
|
proc = await asyncio.create_subprocess_exec(
|
|
|
|
|
"git", "fetch", "--tags", "--force", "origin",
|
|
|
|
|
"git", "fetch", "--tags", "origin", "main",
|
|
|
|
|
cwd=project_root,
|
|
|
|
|
stdout=asyncio.subprocess.PIPE,
|
|
|
|
|
stderr=asyncio.subprocess.PIPE
|
|
|
|
@@ -1137,24 +1137,20 @@ async def check_update():
|
|
|
|
|
if proc.returncode != 0:
|
|
|
|
|
log.warning("git fetch failed: %s", stderr.decode())
|
|
|
|
|
|
|
|
|
|
# Get the latest tag sorted by version (semver-like sorting)
|
|
|
|
|
# This gets all tags, sorts them by version, and takes the last one
|
|
|
|
|
# Get the latest tag reachable from main branch
|
|
|
|
|
proc = await asyncio.create_subprocess_exec(
|
|
|
|
|
"git", "tag", "--sort=version:refname",
|
|
|
|
|
"git", "describe", "--tags", "--abbrev=0", "origin/main",
|
|
|
|
|
cwd=project_root,
|
|
|
|
|
stdout=asyncio.subprocess.PIPE,
|
|
|
|
|
stderr=asyncio.subprocess.PIPE
|
|
|
|
|
)
|
|
|
|
|
stdout, stderr = await proc.communicate()
|
|
|
|
|
if proc.returncode != 0:
|
|
|
|
|
return {"available": None, "error": f"Could not list tags: {stderr.decode()}"}
|
|
|
|
|
return {"available": None, "error": f"No tags found on main branch: {stderr.decode()}"}
|
|
|
|
|
|
|
|
|
|
tags = stdout.decode().strip().split('\n')
|
|
|
|
|
tags = [t for t in tags if t] # Filter empty strings
|
|
|
|
|
if not tags:
|
|
|
|
|
return {"available": None, "error": "No tags found in repository"}
|
|
|
|
|
|
|
|
|
|
latest_tag = tags[-1] # Last tag after version sorting
|
|
|
|
|
latest_tag = stdout.decode().strip()
|
|
|
|
|
if not latest_tag:
|
|
|
|
|
return {"available": None, "error": "No tags found on main branch"}
|
|
|
|
|
|
|
|
|
|
# Get current version
|
|
|
|
|
current_version = (await get_version()).get("version", "unknown")
|
|
|
|
@@ -1172,7 +1168,7 @@ async def check_update():
|
|
|
|
|
|
|
|
|
|
@app.post("/system_update")
|
|
|
|
|
async def system_update():
|
|
|
|
|
"""Update application: git pull release branch (latest tag), poetry install, restart services."""
|
|
|
|
|
"""Update application: git pull main branch (latest tag), poetry install, restart services."""
|
|
|
|
|
try:
|
|
|
|
|
# Best-effort: stop any active streaming cleanly
|
|
|
|
|
try:
|
|
|
|
@@ -1183,10 +1179,10 @@ async def system_update():
|
|
|
|
|
# server -> auracast -> src -> bumble-auracast (3 levels up)
|
|
|
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
|
|
|
|
|
|
|
|
|
|
# 1. Fetch and checkout the latest tag from the release branch
|
|
|
|
|
# First fetch all tags and the release branch
|
|
|
|
|
# 1. Fetch and checkout the latest tag from the main branch
|
|
|
|
|
# First fetch all tags and the main branch
|
|
|
|
|
proc = await asyncio.create_subprocess_exec(
|
|
|
|
|
"git", "fetch", "--tags", "origin", "release",
|
|
|
|
|
"git", "fetch", "--tags", "origin", "main",
|
|
|
|
|
cwd=project_root,
|
|
|
|
|
stdout=asyncio.subprocess.PIPE,
|
|
|
|
|
stderr=asyncio.subprocess.PIPE
|
|
|
|
@@ -1196,9 +1192,9 @@ async def system_update():
|
|
|
|
|
log.error("git fetch failed: %s", stderr.decode())
|
|
|
|
|
raise HTTPException(status_code=500, detail=f"git fetch failed: {stderr.decode()}")
|
|
|
|
|
|
|
|
|
|
# Get the latest tag on the release branch
|
|
|
|
|
# Get the latest tag on the main branch
|
|
|
|
|
proc = await asyncio.create_subprocess_exec(
|
|
|
|
|
"git", "describe", "--tags", "--abbrev=0", "origin/release",
|
|
|
|
|
"git", "describe", "--tags", "--abbrev=0", "origin/main",
|
|
|
|
|
cwd=project_root,
|
|
|
|
|
stdout=asyncio.subprocess.PIPE,
|
|
|
|
|
stderr=asyncio.subprocess.PIPE
|
|
|
|
|