-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (201 loc) · 8.93 KB
/
Copy pathrelease.yml
File metadata and controls
233 lines (201 loc) · 8.93 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
233
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
packages: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 server + client (gnu — musl can't compile OpenH264 C++)
# Use ubuntu-22.04 for glibc 2.35 compatibility (ubuntu-latest = 24.04 = glibc 2.39)
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
suffix: linux-x86_64
build_server: true
build_client: true
# Windows x86_64 server + client
- target: x86_64-pc-windows-msvc
os: windows-latest
suffix: windows-x86_64
build_server: true
build_client: true
# Linux aarch64 cross-compile is temporarily disabled — the
# ports.ubuntu.com arm64 sources have an unresolvable
# libsystemd0:arm64 -> libcap2:arm64 dependency on the
# current ubuntu-22.04 runner image. Re-enable after pinning
# a working sources list (likely needs the security pocket
# and an arm64-only sources.list.d entry instead of editing
# the main sources.list).
# macOS ARM (client only — server needs X11/DXGI for capture)
- target: aarch64-apple-darwin
os: macos-latest
suffix: macos-aarch64
build_server: false
build_client: true
# macOS x86_64
- target: x86_64-apple-darwin
os: macos-latest
suffix: macos-x86_64
build_server: false
build_client: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
# Linux x86_64: install X11 dev libs + nasm (OpenH264) + cmake (opus static build)
- name: Install Linux dependencies (x86_64)
if: contains(matrix.target, 'linux') && !matrix.cross
run: |
sudo apt-get update && sudo apt-get install -y \
libxcb1-dev libxcb-shm0-dev libxcb-randr0-dev libxdo-dev \
nasm cmake \
libpulse-dev libasound2-dev
# macOS: nasm (OpenH264 SIMD asm) + cmake (opus static build)
# macos-latest runners have cmake pre-installed but NOT nasm.
- name: Install macOS dependencies
if: contains(matrix.target, 'apple-darwin')
run: brew install nasm cmake
# Opus's bundled CMakeLists.txt calls cmake_minimum_required below 3.5,
# which CMake 4.x (installed on macos-latest) rejects. Env var tells
# CMake to accept the old policies. Applies globally to all cmake-crate
# invocations. No harm on Linux/Windows runners.
- name: Set CMake policy fallback
run: echo "CMAKE_POLICY_VERSION_MINIMUM=3.5" >> $GITHUB_ENV
shell: bash
# Linux aarch64: cross-compilation toolchain
- name: Install Linux cross-compile dependencies (aarch64)
if: matrix.cross
run: |
sudo dpkg --add-architecture arm64
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
libxcb1-dev:arm64 libxcb-shm0-dev:arm64 libxcb-randr0-dev:arm64 libxdo-dev:arm64 nasm cmake \
libpulse-dev:arm64 libasound2-dev:arm64
- name: Set cross-compile env
if: matrix.cross
run: |
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
# Build WASM for server (Linux native only — Windows/macOS/cross use committed WASM files)
- name: Build WASM
if: matrix.build_server && !contains(matrix.target, 'windows') && !matrix.cross
run: |
cargo install wasm-pack
wasm-pack build crates/web --target web --no-typescript
# Build server (Linux native: with embedded web client from fresh WASM build)
- name: Build server (Linux, with web client)
if: matrix.build_server && !contains(matrix.target, 'windows') && !matrix.cross
run: cargo build --release --target ${{ matrix.target }} -p phantom-server
# Build server (Windows: uses committed WASM files for web-client)
- name: Build server (Windows, with web client)
if: matrix.build_server && contains(matrix.target, 'windows')
run: cargo build --release --target ${{ matrix.target }} -p phantom-server --features audio
# Build server (cross-compile: without web client, with audio)
- name: Build server (cross-compile, no web client)
if: matrix.build_server && matrix.cross
run: cargo build --release --target ${{ matrix.target }} -p phantom-server --no-default-features --features audio,webrtc
# Build client (all platforms: without av1/dav1d for portability)
- name: Build client
if: matrix.build_client
run: cargo build --release --target ${{ matrix.target }} -p phantom-client --no-default-features --features audio
# Package — Unix
- name: Package binaries (Unix)
if: "!contains(matrix.target, 'windows')"
run: |
mkdir -p dist
if [ "${{ matrix.build_server }}" = "true" ]; then
cp target/${{ matrix.target }}/release/phantom-server dist/phantom-server-${{ matrix.suffix }}
fi
if [ "${{ matrix.build_client }}" = "true" ]; then
cp target/${{ matrix.target }}/release/phantom-client dist/phantom-client-${{ matrix.suffix }}
fi
# Package — Windows
- name: Package binaries (Windows)
if: contains(matrix.target, 'windows')
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
if ("${{ matrix.build_server }}" -eq "true") {
Copy-Item "target/${{ matrix.target }}/release/phantom-server.exe" "dist/phantom-server-${{ matrix.suffix }}.exe"
}
if ("${{ matrix.build_client }}" -eq "true") {
Copy-Item "target/${{ matrix.target }}/release/phantom-client.exe" "dist/phantom-client-${{ matrix.suffix }}.exe"
}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.suffix }}
path: dist/*
# Build and push Docker image to GitHub Container Registry
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
ghcr.io/${{ github.repository }}:latest
release:
needs: [build]
# Don't let a single matrix-leg failure (e.g. flaky cross-compile)
# block publishing the rest of the artifacts. download-artifact will
# only pull the legs that actually uploaded.
if: always() && !cancelled()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: find dist -type f && ls -la dist/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
fail_on_unmatched_files: false
body: |
## Install
**Linux / macOS:**
```bash
curl -fsSL https://raw.githubusercontent.com/huaying/phantom/main/install.sh | sh
```
**Windows (PowerShell):**
```powershell
irm https://raw.githubusercontent.com/huaying/phantom/main/install.ps1 | iex
```
**Docker:**
```bash
docker run --rm -p 9900:9900 ghcr.io/huaying/phantom:latest
```
See [README](https://github.com/huaying/phantom#installation) for more options.