-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (203 loc) · 7.9 KB
/
Copy pathbuild-deb.yml
File metadata and controls
232 lines (203 loc) · 7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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