Skip to content

Commit d4031fc

Browse files
ci: add Linux prebuilts with vendor bundling; stub Windows job
1 parent b30def3 commit d4031fc

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

.github/workflows/build-binaries.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,152 @@ jobs:
114114
branch: "ci/prebuilt-darwin-arm64-${{ steps.vars.outputs.abi }}"
115115
add-paths: |
116116
prebuilt/**
117+
118+
build-linux:
119+
if: startsWith(github.ref, 'refs/heads/ci/prebuilt-') == false
120+
runs-on: ubuntu-latest
121+
steps:
122+
- uses: actions/checkout@v4
123+
with:
124+
fetch-depth: 0
125+
- uses: actions/setup-node@v4
126+
with:
127+
node-version: '22'
128+
- name: Install system libraries (OpenSSL, Opus, libsrtp)
129+
run: |
130+
sudo apt-get update
131+
sudo apt-get install -y build-essential cmake ninja-build pkg-config \
132+
libssl-dev libopus-dev libsrtp2-dev patchelf
133+
- name: Clone dependencies (no submodules)
134+
shell: bash
135+
run: |
136+
set -euo pipefail
137+
mkdir -p deps
138+
if [[ ! -d deps/re ]]; then git clone --depth=1 https://github.com/baresip/re.git deps/re; fi
139+
if [[ ! -d deps/baresip ]]; then git clone --depth=1 https://github.com/baresip/baresip.git deps/baresip; fi
140+
- name: Install Node dependencies
141+
run: npm ci
142+
- name: Build libre (re) static and stage SDK
143+
shell: bash
144+
run: |
145+
set -euo pipefail
146+
ROOT="$GITHUB_WORKSPACE"
147+
cd "$ROOT/deps/re"
148+
rm -rf build
149+
cmake -B build -DCMAKE_BUILD_TYPE=Release
150+
cmake --build build -j
151+
mkdir -p "$ROOT/local/re/lib" "$ROOT/local/re/include"
152+
if [[ -f build/libre.a ]]; then cp -a build/libre.a "$ROOT/local/re/lib/"; \
153+
elif [[ -f build/lib/libre.a ]]; then cp -a build/lib/libre.a "$ROOT/local/re/lib/"; \
154+
else echo "libre.a not found" >&2; exit 1; fi
155+
cp -a include/* "$ROOT/local/re/include/"
156+
- name: Build baresip static and stage SDK
157+
shell: bash
158+
run: |
159+
set -euo pipefail
160+
ROOT="$GITHUB_WORKSPACE"
161+
cd "$ROOT/deps/baresip"
162+
rm -rf build
163+
cmake -B build -DSTATIC=ON -DCMAKE_BUILD_TYPE=Release
164+
cmake --build build -j
165+
mkdir -p "$ROOT/local/baresip/lib" "$ROOT/local/baresip/include"
166+
if [[ -f build/libbaresip.a ]]; then cp -a build/libbaresip.a "$ROOT/local/baresip/lib/"; \
167+
elif [[ -f build/lib/libbaresip.a ]]; then cp -a build/lib/libbaresip.a "$ROOT/local/baresip/lib/"; \
168+
else echo "libbaresip.a not found" >&2; exit 1; fi
169+
cp -a include/* "$ROOT/local/baresip/include/"
170+
- name: Build Node addon (cmake-js)
171+
shell: bash
172+
run: |
173+
set -euo pipefail
174+
rm -rf build
175+
npx cmake-js rebuild
176+
- name: Stage prebuilt binary and vendor shared libs
177+
shell: bash
178+
run: |
179+
set -euo pipefail
180+
PLATFORM=$(node -p "process.platform")
181+
ARCH=$(node -p "process.arch")
182+
ABI="node-v$(node -p 'process.versions.modules')"
183+
OUTDIR="prebuilt/${PLATFORM}-${ARCH}/${ABI}"
184+
mkdir -p "$OUTDIR/vendor"
185+
cp -a build/Release/baresip_node.node "$OUTDIR/"
186+
# Set RUNPATH to find vendor and current dir at runtime
187+
patchelf --set-rpath '$ORIGIN:$ORIGIN/vendor' "$OUTDIR/baresip_node.node" || true
188+
# Copy non-system shared libs next to the addon
189+
DEPS=$(ldd "$OUTDIR/baresip_node.node" | awk '{print $3}' | grep -E '^/' | grep -vE '^/lib/|^/lib64/|^/usr/lib/|^/usr/lib64/' || true)
190+
for lib in $DEPS; do base=$(basename "$lib"); cp -n "$lib" "$OUTDIR/vendor/$base" || true; done
191+
- name: Clean build artifacts (keep prebuilt)
192+
run: rm -rf build
193+
- name: Compute Node ABI
194+
id: vars
195+
shell: bash
196+
run: echo "abi=node-v$(node -p 'process.versions.modules')" >> "$GITHUB_OUTPUT"
197+
- name: Create PR with prebuilt binaries (Linux)
198+
uses: peter-evans/create-pull-request@v6
199+
with:
200+
commit-message: "chore: update prebuilt (linux-${{ runner.arch }} ${{ steps.vars.outputs.abi }})"
201+
title: "Update prebuilt binaries (linux-${{ runner.arch }}, ${{ steps.vars.outputs.abi }})"
202+
body: |
203+
Auto-generated by GitHub Actions.
204+
Includes prebuilt binaries for linux-${{ runner.arch }} with Node ABI ${{ steps.vars.outputs.abi }}.
205+
branch: "ci/prebuilt-linux-${{ runner.arch }}-${{ steps.vars.outputs.abi }}"
206+
add-paths: |
207+
prebuilt/**
208+
209+
# build-windows (TODO): Windows support needs dependency strategy (OpenSSL/Opus) and module selection.
210+
# build-windows:
211+
# if: startsWith(github.ref, 'refs/heads/ci/prebuilt-') == false
212+
# runs-on: windows-latest
213+
# steps:
214+
# - uses: actions/checkout@v4
215+
# with:
216+
# fetch-depth: 0
217+
# - uses: actions/setup-node@v4
218+
# with:
219+
# node-version: '22'
220+
# - name: Install tools
221+
# shell: powershell
222+
# run: |
223+
# choco install -y ninja cmake
224+
# - name: Clone dependencies (no submodules)
225+
# shell: bash
226+
# run: |
227+
# set -euo pipefail
228+
# mkdir -p deps
229+
# if [[ ! -d deps/re ]]; then git clone --depth=1 https://github.com/baresip/re.git deps/re; fi
230+
# if [[ ! -d deps/baresip ]]; then git clone --depth=1 https://github.com/baresip/baresip.git deps/baresip; fi
231+
# - name: Install Node dependencies
232+
# run: npm ci
233+
# - name: Build Node addon (cmake-js)
234+
# shell: bash
235+
# run: |
236+
# set -euo pipefail
237+
# rm -rf build
238+
# npx cmake-js rebuild
239+
# - name: Stage prebuilt binary
240+
# shell: bash
241+
# run: |
242+
# set -euo pipefail
243+
# PLATFORM=$(node -p "process.platform")
244+
# ARCH=$(node -p "process.arch")
245+
# ABI="node-v$(node -p 'process.versions.modules')"
246+
# OUTDIR="prebuilt/${PLATFORM}-${ARCH}/${ABI}"
247+
# mkdir -p "$OUTDIR"
248+
# cp -a build/Release/baresip_node.node "$OUTDIR/"
249+
# - name: Clean build artifacts (keep prebuilt)
250+
# run: rmdir /S /Q build
251+
# - name: Compute Node ABI
252+
# id: vars
253+
# shell: bash
254+
# run: echo "abi=node-v$(node -p 'process.versions.modules')" >> "$GITHUB_OUTPUT"
255+
# - name: Create PR with prebuilt binaries (Windows)
256+
# uses: peter-evans/create-pull-request@v6
257+
# with:
258+
# commit-message: "chore: update prebuilt (win32-${{ runner.arch }} ${{ steps.vars.outputs.abi }})"
259+
# title: "Update prebuilt binaries (win32-${{ runner.arch }}, ${{ steps.vars.outputs.abi }})"
260+
# body: |
261+
# Auto-generated by GitHub Actions.
262+
# Includes prebuilt binaries for win32-${{ runner.arch }} with Node ABI ${{ steps.vars.outputs.abi }}.
263+
# branch: "ci/prebuilt-win32-${{ runner.arch }}-${{ steps.vars.outputs.abi }}"
264+
# add-paths: |
265+
# prebuilt/**

0 commit comments

Comments
 (0)