feat: production-ready Linux & macOS support
- Add `linux` (dbus-python, PyGObject, python-xlib) and `macos`
(pyobjc) extras to pyproject.toml with sys_platform markers; move
cross-platform screen-brightness-control + monitorcontrol to base deps.
- build-dist-linux.sh: install `.[linux]`, pkg-config pre-flight for
dbus-1/glib-2.0, emit a systemd unit with DBUS_SESSION_BUS_ADDRESS +
XDG_RUNTIME_DIR + ReadWritePaths for ~/.config and ~/.cache so MPRIS
works and audit-log / thumbnail writes aren't blocked by ProtectHome.
- New build-dist-macos.sh + per-user LaunchAgent installer producing
MediaServer-vX.Y-macos-{arm64,x86_64}.tar.gz.
- Templated media-server.service updated to match the dist layout with
proper session-bus env vars and a writable state-dir grant.
- install_linux.sh: drop dead requirements.txt path; install via
`pip install ".[linux]"` and pre-create the writable state dirs.
- Cross-platform album artwork: abstract MediaController.get_album_art()
with Linux (mpris:artUrl, file:// + http(s)://) and macOS (Spotify URL)
impls; routes/media artwork endpoint now awaits the controller.
- LinuxMediaController connects to the session bus lazily — failure no
longer crashes lifespan startup; MPRIS calls return idle until the bus
is reachable. Logged once at INFO with a hint about
`loginctl enable-linger`.
- Startup preflight on Linux warns if DBUS_SESSION_BUS_ADDRESS or
XDG_RUNTIME_DIR is unset and informs the user when Wayland disables
the foreground probe.
- /api/media/visualizer/status now reports a per-OS unavailable_reason.
- tray._confirm guarded against ctypes.windll on non-Windows.
- config.example.yaml: per-OS commented script examples; on_turn_off
default is now a no-op echo (used to silently fail off Windows).
- README: replace stale `pip install -r requirements.txt` instructions
with the new extras; add systemd lingering doc + troubleshooting
section; add macOS LaunchAgent section.
- CI: new linux-smoke job (installs `.[linux]`, boots the server under
dbus-run-session, asserts /api/health). Release workflow gains
apt-deps step for the Linux build and a best-effort macOS build job.
This commit is contained in:
@@ -60,6 +60,8 @@ jobs:
|
||||
| Windows (installer) | \`MediaServer-{tag}-setup.exe\` |
|
||||
| Windows (portable) | \`MediaServer-{tag}-win-x64.zip\` |
|
||||
| Linux | \`MediaServer-{tag}-linux-x64.tar.gz\` |
|
||||
| macOS (Apple Silicon) | \`MediaServer-{tag}-macos-arm64.tar.gz\` |
|
||||
| macOS (Intel) | \`MediaServer-{tag}-macos-x86_64.tar.gz\` |
|
||||
''').strip())
|
||||
|
||||
print(json.dumps('\n\n'.join(sections)))
|
||||
@@ -187,6 +189,13 @@ jobs:
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install native deps for dbus-python + PyGObject
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
libdbus-1-dev libglib2.0-dev pkg-config \
|
||||
libcairo2-dev libgirepository1.0-dev
|
||||
|
||||
- name: Build Linux distribution
|
||||
run: |
|
||||
chmod +x build-dist-linux.sh
|
||||
@@ -226,3 +235,62 @@ jobs:
|
||||
-H "Authorization: token $DEPLOY_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@$FILE"
|
||||
|
||||
# --- Build macOS tarball (best-effort; requires a macos runner) ---
|
||||
# PyObjC wheels are macOS-only, so this job must run on a real Mac.
|
||||
# If your Gitea instance has no macos runners, the job is skipped at
|
||||
# scheduling time and the rest of the release still ships.
|
||||
build-macos:
|
||||
needs: create-release
|
||||
runs-on: macos-latest
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Build frontend
|
||||
run: npm ci && npm run build
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Build macOS distribution
|
||||
run: |
|
||||
chmod +x build-dist-macos.sh
|
||||
./build-dist-macos.sh "${{ gitea.ref_name }}"
|
||||
|
||||
- name: Upload assets to release
|
||||
env:
|
||||
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
run: |
|
||||
RELEASE_ID="${{ needs.create-release.outputs.release_id }}"
|
||||
BASE_URL="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
||||
|
||||
FILE=$(ls build/MediaServer-*-macos-*.tar.gz | head -1)
|
||||
NAME=$(basename "$FILE")
|
||||
|
||||
EXISTING=$(curl -s "$BASE_URL/releases/$RELEASE_ID/assets" \
|
||||
-H "Authorization: token $DEPLOY_TOKEN")
|
||||
ASSET_ID=$(echo "$EXISTING" | python3 -c "
|
||||
import sys, json
|
||||
assets = json.load(sys.stdin)
|
||||
for a in assets:
|
||||
if a['name'] == '$NAME':
|
||||
print(a['id'])
|
||||
break
|
||||
" 2>/dev/null || true)
|
||||
|
||||
if [ -n "$ASSET_ID" ]; then
|
||||
curl -s -X DELETE "$BASE_URL/releases/$RELEASE_ID/assets/$ASSET_ID" \
|
||||
-H "Authorization: token $DEPLOY_TOKEN"
|
||||
fi
|
||||
|
||||
curl -s -X POST \
|
||||
"$BASE_URL/releases/$RELEASE_ID/assets?name=$NAME" \
|
||||
-H "Authorization: token $DEPLOY_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@$FILE"
|
||||
|
||||
@@ -34,3 +34,64 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: pytest --tb=short -q || test $? -eq 5
|
||||
|
||||
# Linux smoke test: install the linux extra in the same way build-dist-linux.sh
|
||||
# does, then boot the server and hit /api/health. Catches dependency-resolution
|
||||
# and import-time regressions for the Linux distribution path.
|
||||
linux-smoke:
|
||||
if: "!startsWith(github.event.head_commit.message, 'chore: release')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Build frontend
|
||||
run: npm ci && npm run build
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install Linux system deps for dbus-python + PyGObject
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
libdbus-1-dev libglib2.0-dev pkg-config \
|
||||
libcairo2-dev libgirepository1.0-dev
|
||||
|
||||
- name: Install with linux extra
|
||||
run: |
|
||||
pip install --upgrade pip
|
||||
pip install ".[linux]"
|
||||
|
||||
- name: Smoke — server boots and /api/health responds
|
||||
run: |
|
||||
# Headless Linux runners have no PulseAudio and no display
|
||||
# server, so we disable the visualizer + update checker, and we
|
||||
# use `dbus-run-session` to give LinuxMediaController a real
|
||||
# session bus to talk to (otherwise dbus.SessionBus() would
|
||||
# raise during startup). This isn't a full MPRIS integration
|
||||
# test — it only proves the dispatcher selects the Linux
|
||||
# controller, all imports resolve, and /api/health returns 200.
|
||||
sudo apt-get install -y --no-install-recommends dbus-x11
|
||||
export MEDIA_SERVER_VISUALIZER_ENABLED=false
|
||||
export MEDIA_SERVER_UPDATE_CHECK_ENABLED=false
|
||||
dbus-run-session -- bash -c '
|
||||
python -m media_server.main --no-tray --port 18765 &
|
||||
SERVER_PID=$!
|
||||
for i in $(seq 1 30); do
|
||||
if curl -sf "http://127.0.0.1:18765/api/health" >/dev/null; then
|
||||
echo "Health check passed"
|
||||
kill $SERVER_PID
|
||||
wait $SERVER_PID 2>/dev/null || true
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
echo "Server did not respond within 15s"
|
||||
kill $SERVER_PID 2>/dev/null || true
|
||||
exit 1
|
||||
'
|
||||
|
||||
Reference in New Issue
Block a user