Skip to content

Commit c54c9f9

Browse files
authored
Merge pull request #2 from moq-dev/release-scripts
Add R2 upload and Windows build script
2 parents 2ee93ce + 031be1a commit c54c9f9

10 files changed

Lines changed: 451 additions & 0 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build_macos/
2+
build_ubuntu/
3+
build_x64/
4+
build_linux/
5+
.deps/
6+
.wrangler/

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33

44
# Except for default project files
5+
!/release
56
!/.github
67
!/build-aux
78
!/cmake
@@ -19,6 +20,7 @@
1920
!.git-blame-ignore-devs
2021
!.gitmodules
2122
!.gitignore
23+
!.dockerignore
2224
!.mailmap
2325
!.swift-format
2426
!AUTHORS
@@ -31,6 +33,7 @@
3133
!COPYING
3234
!INSTALL
3335
!README.rst
36+
!wrangler.toml
3437

3538
# Exclude lock files
3639
*.lock.json
@@ -43,6 +46,9 @@
4346
# Exclude modified Flatpak files
4447
build-aux/flatpak-github-action-modified-*
4548

49+
# Exclude Wrangler cache
50+
.wrangler/
51+
4652
# Exclude macOS legacy resource forks
4753
.DS_Store
4854

release/.env

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Apple code signing certificate (PKCS12 format, base64 encoded)
2+
APPLE_CERTIFICATE="op://hang.live/apple-certificate/text"
3+
APPLE_CERTIFICATE_PASSWORD="op://hang.live/apple-certificate/password"
4+
5+
# Apple Developer Team ID
6+
APPLE_TEAM_ID="D7D5SDDB5Z"
7+
8+
# Optional: For notarization (uncomment and set correct references when needed)
9+
# APPLE_ID="op://hang.live/apple-notarization/username"
10+
# APPLE_PASSWORD="op://hang.live/apple-notarization/password"
11+
12+
# R2 bucket for uploading release artifacts
13+
R2_BUCKET="moqbs"

release/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM --platform=linux/amd64 ubuntu:24.04 AS build
2+
3+
# Install build deps (from .github/scripts/utils.zsh/setup_ubuntu)
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential cmake ninja-build git curl ca-certificates jq pkg-config \
6+
libglib2.0-dev extra-cmake-modules lsb-release \
7+
libcurl4-openssl-dev \
8+
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
9+
libswresample-dev libswscale-dev \
10+
libjansson-dev libx11-xcb-dev libgles2-mesa-dev \
11+
libwayland-dev libpipewire-0.3-dev libpulse-dev \
12+
libx264-dev libmbedtls-dev libgl1-mesa-dev \
13+
uthash-dev libsimde-dev \
14+
libluajit-5.1-dev python3-dev swig libcmocka-dev \
15+
libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \
16+
libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev \
17+
libxss-dev libglvnd-dev libxkbcommon-dev \
18+
libatk1.0-dev libatk-bridge2.0-dev libxcomposite-dev libxdamage-dev \
19+
libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev \
20+
libjack-jackd2-dev libsndio-dev libspeexdsp-dev \
21+
libudev-dev libv4l-dev libva-dev libvlc-dev libpci-dev libdrm-dev \
22+
nlohmann-json3-dev libwebsocketpp-dev libasio-dev libqrcodegencpp-dev \
23+
libffmpeg-nvenc-dev librist-dev libsrt-openssl-dev \
24+
qt6-base-dev libqt6svg6-dev qt6-base-private-dev \
25+
libvpl-dev libvpl2 libnss3-dev libnspr4-dev xz-utils file \
26+
&& rm -rf /var/lib/apt/lists/*
27+
28+
WORKDIR /build
29+
COPY . .
30+
31+
# Download CEF (parse version from CMakePresets.json)
32+
RUN CEF_VERSION=$(jq -r '.configurePresets[] | select(.name=="dependencies") | .vendor["obsproject.com/obs-studio"].dependencies.cef.version' CMakePresets.json) && \
33+
CEF_REVISION=$(jq -r '.configurePresets[] | select(.name=="dependencies") | .vendor["obsproject.com/obs-studio"].dependencies.cef.revision["ubuntu-x86_64"] // empty' CMakePresets.json) && \
34+
CEF_HASH=$(jq -r '.configurePresets[] | select(.name=="dependencies") | .vendor["obsproject.com/obs-studio"].dependencies.cef.hashes["ubuntu-x86_64"]' CMakePresets.json) && \
35+
mkdir -p .deps && cd .deps && \
36+
FILENAME="cef_binary_${CEF_VERSION}_linux_x86_64${CEF_REVISION:+_v${CEF_REVISION}}.tar.xz" && \
37+
curl -fSLO "https://cdn-fastly.obsproject.com/downloads/${FILENAME}" && \
38+
echo "${CEF_HASH} ${FILENAME}" | sha256sum -c - && \
39+
mkdir -p "cef_binary_${CEF_VERSION}_linux_x86_64" && \
40+
tar --strip-components=1 -xJf "${FILENAME}" -C "cef_binary_${CEF_VERSION}_linux_x86_64"
41+
42+
# Configure + Build + Package
43+
RUN CEF_VERSION=$(jq -r '.configurePresets[] | select(.name=="dependencies") | .vendor["obsproject.com/obs-studio"].dependencies.cef.version' CMakePresets.json) && \
44+
cmake -S . --preset ubuntu \
45+
-DCMAKE_BUILD_TYPE=Release \
46+
-DENABLE_BROWSER=ON \
47+
-DCEF_ROOT_DIR="/build/.deps/cef_binary_${CEF_VERSION}_linux_x86_64" && \
48+
cmake --build build_ubuntu --config Release --parallel && \
49+
cd build_ubuntu && cpack -C Release

release/justfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env just --justfile
2+
3+
# List available commands
4+
default:
5+
@just --list
6+
7+
# Build for ARM (native on Apple Silicon)
8+
build:
9+
op run --env-file=".env" -- bash ./release-mac arm64 RelWithDebInfo false
10+
11+
# Build release version for ARM
12+
release:
13+
op run --env-file=".env" -- bash ./release-mac arm64 Release false
14+
15+
# Build for ARM with notarization (slow)
16+
release-notarized:
17+
op run --env-file=".env" -- bash ./release-mac arm64 Release true
18+
19+
# Cross-compile for Intel Macs (x86_64)
20+
build-intel:
21+
op run --env-file=".env" -- bash ./release-mac x86_64 RelWithDebInfo false
22+
23+
# Release for Intel Macs
24+
release-intel:
25+
op run --env-file=".env" -- bash ./release-mac x86_64 Release false
26+
27+
# Build for Windows x64 (run on Windows machine)
28+
build-windows:
29+
pwsh -File ./release-windows.ps1
30+
31+
# Release for Windows x64 with R2 upload (run on Windows machine)
32+
release-windows:
33+
op run --env-file=".env" -- pwsh -File ./release-windows.ps1
34+
35+
# Build for Linux x86_64 (via Docker)
36+
build-linux:
37+
bash ./release-linux
38+
39+
# Release for Linux x86_64 with R2 upload (via Docker)
40+
release-linux:
41+
op run --env-file=".env" -- bash ./release-linux
42+
43+
# Clean macOS build artifacts
44+
clean:
45+
rm -rf ../build_macos
46+
47+
# Clean Windows build artifacts
48+
clean-windows:
49+
pwsh -Command "if (Test-Path ../build_x64) { Remove-Item -Recurse -Force ../build_x64 }"
50+
51+
# Clean Linux build artifacts
52+
clean-linux:
53+
rm -rf ../build_linux

release/lib/keychain.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
setup_signing_keychain() {
4+
local temp_dir="$1"
5+
6+
# Decode certificate
7+
local cert_path="$temp_dir/certificate.p12"
8+
echo -n "$APPLE_CERTIFICATE" | base64 --decode > "$cert_path"
9+
10+
# Create temporary keychain
11+
local keychain_password="$(openssl rand -base64 32)"
12+
local keychain_path="$temp_dir/signing.keychain-db"
13+
14+
security create-keychain -p "$keychain_password" "$keychain_path"
15+
security set-keychain-settings -lut 21600 "$keychain_path"
16+
security unlock-keychain -p "$keychain_password" "$keychain_path"
17+
18+
# Import certificate
19+
security import "$cert_path" \
20+
-P "$APPLE_CERTIFICATE_PASSWORD" \
21+
-A -t cert -f pkcs12 \
22+
-k "$keychain_path" \
23+
-T /usr/bin/codesign \
24+
-T /usr/bin/security \
25+
-T /usr/bin/xcrun
26+
27+
# Allow codesign to access without prompt
28+
security set-key-partition-list \
29+
-S 'apple-tool:,apple:' \
30+
-k "$keychain_password" \
31+
"$keychain_path" &> /dev/null
32+
33+
# Add to search list
34+
security list-keychain -d user -s "$keychain_path" $(security list-keychains -d user | tr -d '"')
35+
36+
# Store for cleanup
37+
echo "$keychain_path" > "$temp_dir/keychain_path"
38+
39+
# Extract identity
40+
local identity=$(security find-identity -v -p codesigning "$keychain_path" | \
41+
grep "Developer ID Application" | \
42+
sed -n 's/.*"\(.*\)"/\1/p' | \
43+
head -n 1)
44+
45+
if [ -z "$identity" ]; then
46+
echo "Error: Could not find Developer ID Application identity" >&2
47+
return 1
48+
fi
49+
50+
echo "$identity"
51+
}
52+
53+
cleanup_signing_keychain() {
54+
local temp_dir="$1"
55+
56+
if [ -f "$temp_dir/keychain_path" ]; then
57+
local keychain_path=$(cat "$temp_dir/keychain_path")
58+
security delete-keychain "$keychain_path" 2>/dev/null || true
59+
fi
60+
}

release/release-linux

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
6+
7+
# Compute version
8+
OBS_VERSION=$(git -C "$PROJECT_ROOT" describe --tags --always | sed 's/-moqbs.*//')
9+
COMMIT_HASH=$(git -C "$PROJECT_ROOT" rev-parse --short=7 HEAD)
10+
VERSION="${OBS_VERSION}-${COMMIT_HASH}"
11+
echo "Version: $VERSION"
12+
13+
# Build Docker image
14+
echo "Building Docker image..."
15+
docker build --platform linux/amd64 -t moqbs-linux -f "$SCRIPT_DIR/Dockerfile" "$PROJECT_ROOT"
16+
17+
# Extract DEB from container
18+
echo "Extracting artifact..."
19+
CONTAINER_ID=$(docker create --platform linux/amd64 moqbs-linux)
20+
mkdir -p "$PROJECT_ROOT/build_linux"
21+
22+
# Find the .deb filename inside the container (exclude debug .ddeb)
23+
DEB_PATH=$(docker run --rm --platform linux/amd64 moqbs-linux sh -c 'ls /build/build_ubuntu/*.deb 2>/dev/null | grep -v dbgsym | head -1')
24+
if [ -z "$DEB_PATH" ]; then
25+
docker rm "$CONTAINER_ID"
26+
echo "Error: No .deb found in build output"
27+
exit 1
28+
fi
29+
30+
OUTPUT_NAME="moqbs-linux-x86_64.deb"
31+
docker cp "$CONTAINER_ID:$DEB_PATH" "$PROJECT_ROOT/build_linux/$OUTPUT_NAME"
32+
docker rm "$CONTAINER_ID"
33+
echo "Created: $PROJECT_ROOT/build_linux/$OUTPUT_NAME"
34+
35+
# Upload to R2
36+
if [ -n "${R2_BUCKET:-}" ]; then
37+
echo "Uploading to R2..."
38+
bunx wrangler r2 object put "$R2_BUCKET/linux/x86_64/$VERSION/$OUTPUT_NAME" \
39+
--remote --file "$PROJECT_ROOT/build_linux/$OUTPUT_NAME"
40+
echo "Uploaded: https://obs.moq.dev/linux/x86_64/$VERSION/$OUTPUT_NAME"
41+
fi
42+
43+
echo ""
44+
echo "Build complete!"
45+
echo "DEB: $PROJECT_ROOT/build_linux/$OUTPUT_NAME"

0 commit comments

Comments
 (0)