Skip to content

feat: ghcr for client python #25

feat: ghcr for client python

feat: ghcr for client python #25

Workflow file for this run

name: Build .deb Package for Raspberry Pi
on:
push:
branches: [master]
workflow_dispatch:
permissions:
contents: write
env:
PKG_NAME: splintercom-client
PKG_ARCH: arm64
PKG_DEPENDS: "libgstreamer1.0-0, gstreamer1.0-plugins-base, gstreamer1.0-plugins-good, libv4l-0"
jobs:
test:
name: Run tests
runs-on: ubuntu-22.04-arm
steps:
- name: Record job start time
run: echo "JOB_START_MS=$(date +%s%3N)" >> "$GITHUB_ENV"
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install dependencies
run: uv sync
- name: Run tests
run: uv run pytest
- name: Send CI metrics to Honeycomb
if: always()
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
JOB_STATUS: ${{ job.status }}
run: |
END_MS=$(date +%s%3N)
DURATION_MS=$((END_MS - JOB_START_MS))
COMMIT_MSG=$(git log -1 --pretty=format:%s 2>/dev/null || echo "")
curl -s -X POST "https://api.honeycomb.io/1/events/github-actions" \
-H "X-Honeycomb-Team: $HONEYCOMB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Honeycomb-Event-Time: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-d "$(jq -cn \
--arg workflow "$GITHUB_WORKFLOW" \
--arg job "$GITHUB_JOB" \
--arg status "$JOB_STATUS" \
--argjson duration_ms "$DURATION_MS" \
--arg sha "$GITHUB_SHA" \
--arg ref "$GITHUB_REF_NAME" \
--arg actor "$GITHUB_ACTOR" \
--arg repository "$GITHUB_REPOSITORY" \
--argjson run_id "$GITHUB_RUN_ID" \
--argjson run_number "$GITHUB_RUN_NUMBER" \
--arg commit_message "$COMMIT_MSG" \
'{workflow: $workflow, job: $job, status: $status, duration_ms: $duration_ms,
sha: $sha, ref: $ref, actor: $actor, repository: $repository,
run_id: $run_id, run_number: $run_number, commit_message: $commit_message}')" || true
build:
name: Build .deb
needs: test
runs-on: ubuntu-22.04-arm
steps:
- name: Record job start time
run: echo "JOB_START_MS=$(date +%s%3N)" >> "$GITHUB_ENV"
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: uv.lock
- name: Install project dependencies
run: uv sync
- name: Install Nuitka
run: uv pip install nuitka
- name: Cache Nuitka build output
uses: actions/cache@v4
with:
path: |
dist/
build/
main.build/
main.dist/
main.onefile-build/
key: nuitka-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('uv.lock', 'main.py', 'splintercomclient/**/*.py') }}
- name: Build native binary with Nuitka
run: >
uv run python -m nuitka
--standalone
--onefile
--output-filename=splintercom-client
--output-dir=dist
--include-package=splintercomclient
--include-package=aiortc
--include-package=av
--include-package=cv2
--include-package=numpy
--include-package=websockets
--include-package=requests
--include-package=jsonschema
--include-package=boto3
--include-package=botocore
--include-package=cryptography
--include-package=cffi
--include-package=jmespath
--include-package=transparenc_sdk
--include-package-data=opencv_python.libs
--include-package-data=cv2
main.py
- name: Build .deb package
run: |
set -euo pipefail
APP_VERSION=$(cat VERSION)
# Debian package versions can't contain '+'; '~' sorts correctly as pre-release
PKG_VERSION=$(echo "$APP_VERSION" | tr '+' '~')
PKG_DIR="dist/${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}"
DEB_FILE="${PKG_DIR}.deb"
mkdir -p "${PKG_DIR}/usr/local/bin"
mkdir -p "${PKG_DIR}/lib/systemd/system"
mkdir -p "${PKG_DIR}/etc/splintercom-client"
mkdir -p "${PKG_DIR}/DEBIAN"
cp dist/splintercom-client "${PKG_DIR}/usr/local/bin/"
chmod 755 "${PKG_DIR}/usr/local/bin/splintercom-client"
cat > "${PKG_DIR}/DEBIAN/control" <<EOF
Package: ${PKG_NAME}
Version: ${PKG_VERSION}
Section: net
Priority: optional
Architecture: ${PKG_ARCH}
Depends: ${PKG_DEPENDS}
Maintainer: Splintercom Team
Description: Splintercom Pi client for WebRTC live streaming
Raspberry Pi client that connects to the splintercom signaling server
and streams live video via WebRTC.
EOF
cat > "${PKG_DIR}/etc/splintercom-client/env" <<EOF
# Splintercom Client Configuration
# Set your environment variables here — these are sourced by the systemd service.
#
# OAUTH_CLIENT_ID=your_client_id
# OAUTH_CLIENT_SECRET=your_client_secret
# VIDEO_SOURCE=0
# TOKEN_FILE_PATH=/home/pi/.config/splintercom-client/tokens.json
# WEBSOCKET_API_BASE_URL=wss://your-server.com/ws/live_stream
# HTTP_API_BASE_URL=https://your-server.com
EOF
cat > "${PKG_DIR}/lib/systemd/system/splintercom-client.service" <<EOF
[Unit]
Description=Splintercom Pi Client
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
Group=pi
EnvironmentFile=-/etc/splintercom-client/env
ExecStart=/usr/local/bin/splintercom-client
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
dpkg-deb --build "${PKG_DIR}"
echo "--- Built package ---"
ls -lh "${DEB_FILE}"
echo ""
echo "--- Package contents ---"
dpkg-deb --contents "${DEB_FILE}"
echo ""
echo "--- Package info ---"
dpkg-deb --info "${DEB_FILE}"
- name: Upload .deb artifact
uses: actions/upload-artifact@v4
with:
name: splintercom-client-deb
path: dist/splintercom-client_*.deb
retention-days: 30
- name: Send CI metrics to Honeycomb
if: always()
env:
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }}
JOB_STATUS: ${{ job.status }}
run: |
END_MS=$(date +%s%3N)
DURATION_MS=$((END_MS - JOB_START_MS))
COMMIT_MSG=$(git log -1 --pretty=format:%s 2>/dev/null || echo "")
curl -s -X POST "https://api.honeycomb.io/1/events/github-actions" \
-H "X-Honeycomb-Team: $HONEYCOMB_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Honeycomb-Event-Time: $(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-d "$(jq -cn \
--arg workflow "$GITHUB_WORKFLOW" \
--arg job "$GITHUB_JOB" \
--arg status "$JOB_STATUS" \
--argjson duration_ms "$DURATION_MS" \
--arg sha "$GITHUB_SHA" \
--arg ref "$GITHUB_REF_NAME" \
--arg actor "$GITHUB_ACTOR" \
--arg repository "$GITHUB_REPOSITORY" \
--argjson run_id "$GITHUB_RUN_ID" \
--argjson run_number "$GITHUB_RUN_NUMBER" \
--arg commit_message "$COMMIT_MSG" \
'{workflow: $workflow, job: $job, status: $status, duration_ms: $duration_ms,
sha: $sha, ref: $ref, actor: $actor, repository: $repository,
run_id: $run_id, run_number: $run_number, commit_message: $commit_message}')" || true