update_from_main (#20)

- implement updates from main

Co-authored-by: pstruebi <patrick.struebin@summitwave.eu>
Reviewed-on: https://gitea.pstruebi.xyz/auracaster/bumble-auracast/pulls/20
This commit was merged in pull request #20.
This commit is contained in:
2026-01-20 16:52:29 +01:00
parent 59ca5dafd2
commit 7b77aa9042
3 changed files with 27 additions and 20 deletions

11
AGENTS.md Normal file
View File

@@ -0,0 +1,11 @@
# AGENTS.md
## Setup commands
- this projects uses poetry for package management
- if something should be run in a python env use 'poetry run'
## Application
- this is a bluetooth Auracast transmitter application
- it consists of multicast_frontend.py and multicast_server.py mainly which connect to each other via a rest api

View File

@@ -24,7 +24,7 @@ from auracast.utils.frontend_auth import (
_THIS_DIR = os.path.dirname(__file__) _THIS_DIR = os.path.dirname(__file__)
_FAVICON_PATH = os.path.abspath(os.path.join(_THIS_DIR, '..', 'utils', 'favicon.ico')) _FAVICON_PATH = os.path.abspath(os.path.join(_THIS_DIR, '..', 'utils', 'favicon.ico'))
favicon = Image.open(_FAVICON_PATH) favicon = Image.open(_FAVICON_PATH)
st.set_page_config(page_title="Castbox", page_icon=favicon, layout="centered") st.set_page_config(page_title="Beacon", page_icon=favicon, layout="centered")
# Load environment variables from a .env file if present # Load environment variables from a .env file if present
load_dotenv() load_dotenv()

View File

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