Skip to content

ci: package headers with mac artifact #21

ci: package headers with mac artifact

ci: package headers with mac artifact #21

Workflow file for this run

name: Build Native Libs
on:
workflow_dispatch:
inputs:
libvpx-ref:
description: libvpx git ref to checkout
required: false
default: v1.15.2
build-macos:
description: Build macOS binaries
required: false
default: "true"
build-ios:
description: Build iOS binaries
required: false
default: "true"
build-android:
description: Build Android binaries
required: false
default: "true"
build-html5:
description: Build HTML5 binaries
required: false
default: "true"
build-windows:
description: Build Windows binaries
required: false
default: "true"
push:
env:
LIBVPX_REF: ${{ inputs.libvpx-ref || 'v1.15.2' }}
permissions:
contents: write
jobs:
macos:
name: macOS
runs-on: macos-13
if: ${{ github.event_name == 'push' || inputs.build-macos != 'false' }}
steps:
- uses: actions/checkout@v4
- name: Install build deps
run: |
brew update
brew install yasm
- name: Fetch libvpx
run: git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 libvpx
- name: Build macOS libs
run: |
pushd libvpx
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_osx.sh" x86_64
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_osx.sh" arm64
pushd third_party/libwebm
bash "$GITHUB_WORKSPACE/videoplayer/utils/webm/build_osx.sh" x86_64
bash "$GITHUB_WORKSPACE/videoplayer/utils/webm/build_osx.sh" arm64
popd
popd
- name: Collect artifacts
run: |
mkdir -p artifacts/videoplayer/lib/{x86_64-osx,arm64-osx} artifacts/videoplayer/include
cp libvpx/build-x86_64-osx/libvpx.a artifacts/videoplayer/lib/x86_64-osx/
cp libvpx/build-arm64-osx/libvpx.a artifacts/videoplayer/lib/arm64-osx/
cp libvpx/third_party/libwebm/build/osx/x86_64/libwebm.a artifacts/videoplayer/lib/x86_64-osx/
cp libvpx/third_party/libwebm/build/osx/arm64/libwebm.a artifacts/videoplayer/lib/arm64-osx/
rsync -a --include '*/' --include '*.h' --exclude '*' libvpx/vpx/ artifacts/videoplayer/include/vpx/
rsync -a --include '*/' --include '*.h' --exclude '*' libvpx/vpx_ports/ artifacts/videoplayer/include/vpx_ports/
if [[ -f libvpx/examples/webmdec.h ]]; then
mkdir -p artifacts/videoplayer/include/webm
cp libvpx/examples/webmdec.h artifacts/videoplayer/include/webm/webmdec.h
fi
if [[ -f libvpx/build-x86_64-osx/vpx_config.h ]]; then
cp libvpx/build-x86_64-osx/vpx_config.h artifacts/videoplayer/include/vpx_config.h
fi
- uses: actions/upload-artifact@v4
with:
name: libs-macos
path: artifacts
ios:
name: iOS
runs-on: macos-13
if: ${{ github.event_name == 'push' || inputs.build-ios != 'false' }}
steps:
- uses: actions/checkout@v4
- name: Install build deps
run: |
brew update
brew install yasm
- name: Fetch libvpx
run: git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 libvpx
- name: Build iOS libs
env:
MIN_IOS_VERSION: "12.0"
run: |
pushd libvpx
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_ios.sh" arm64
pushd third_party/libwebm
bash "$GITHUB_WORKSPACE/videoplayer/utils/webm/build_ios.sh" arm64
popd
popd
- name: Collect artifacts
run: |
mkdir -p artifacts/videoplayer/lib/arm64-ios
cp libvpx/build-arm64-ios/libvpx.a artifacts/videoplayer/lib/arm64-ios/
cp libvpx/third_party/libwebm/build/ios/arm64/libwebm.a artifacts/videoplayer/lib/arm64-ios/
- uses: actions/upload-artifact@v4
with:
name: libs-ios
path: artifacts
android:
name: Android
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' || inputs.build-android != 'false' }}
steps:
- uses: actions/checkout@v4
- name: Install toolchain
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
- name: Install build deps
run: sudo apt-get update && sudo apt-get install -y build-essential yasm
- name: Fetch libvpx
run: git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 libvpx
- name: Build Android libs
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$ANDROID_SDK_ROOT/ndk/25.2.9519653}"
pushd libvpx
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_android.sh" armv7
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_android.sh" arm64
TOOLCHAIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64"
SYSROOT="$TOOLCHAIN/sysroot"
build_webm() {
local arch="$1"
local target="$2"
local outdir="$3"
local cxx="$TOOLCHAIN/bin/${target}-clang++"
local ar="$TOOLCHAIN/bin/llvm-ar"
mkdir -p "${outdir}"
pushd "${outdir}"
for f in ../../common/file_util.cc ../../common/hdr_util.cc ../../mkvparser/mkvparser.cc ../../mkvparser/mkvreader.cc ../../mkvmuxer/mkvmuxer.cc ../../mkvmuxer/mkvmuxerutil.cc ../../mkvmuxer/mkvwriter.cc; do
${cxx} -c "../${f}" -o "$(basename "${f}").cpp_0.o" \
--target="${target}" \
--sysroot="${SYSROOT}" \
-std=c++11 \
-fPIC \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-Wno-extern-c-compat \
-I../../.. || exit 1
done
${ar} rcs libwebm.a file_util.cc.cpp_0.o hdr_util.cc.cpp_0.o mkvparser.cc.cpp_0.o mkvreader.cc.cpp_0.o mkvmuxer.cc.cpp_0.o mkvmuxerutil.cc.cpp_0.o mkvwriter.cc.cpp_0.o
popd
}
pushd third_party/libwebm
build_webm armv7 armv7a-linux-androideabi21 build/android/armv7
build_webm arm64 aarch64-linux-android21 build/android/arm64
popd
popd
- name: Collect artifacts
run: |
mkdir -p artifacts/videoplayer/lib/armv7-android artifacts/videoplayer/lib/arm64-android
cp libvpx/build-armv7-android/libvpx.a artifacts/videoplayer/lib/armv7-android/
cp libvpx/build-arm64-android/libvpx.a artifacts/videoplayer/lib/arm64-android/
cp libvpx/third_party/libwebm/build/android/armv7/libwebm.a artifacts/videoplayer/lib/armv7-android/
cp libvpx/third_party/libwebm/build/android/arm64/libwebm.a artifacts/videoplayer/lib/arm64-android/
test -f artifacts/videoplayer/lib/armv7-android/libvpx.a
test -f artifacts/videoplayer/lib/armv7-android/libwebm.a
test -f artifacts/videoplayer/lib/arm64-android/libvpx.a
test -f artifacts/videoplayer/lib/arm64-android/libwebm.a
- uses: actions/upload-artifact@v4
with:
name: libs-android
path: artifacts
html5:
name: HTML5
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' || inputs.build-html5 != 'false' }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential python3 yasm
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v13
with:
version: "3.1.45"
- name: Fetch libvpx
run: git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 libvpx
- name: Build HTML5 libs
run: |
source "$EMSDK/emsdk_env.sh"
pushd libvpx
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_html5.sh" js
bash "$GITHUB_WORKSPACE/videoplayer/utils/vpx/build_html5.sh" wasm
pushd third_party/libwebm
build_webm() {
local wasm="$1"
local outdir="$2"
mkdir -p "${outdir}"
pushd "${outdir}"
for f in ../../common/file_util.cc ../../common/hdr_util.cc ../../mkvparser/mkvparser.cc ../../mkvparser/mkvreader.cc ../../mkvmuxer/mkvmuxer.cc ../../mkvmuxer/mkvmuxerutil.cc ../../mkvmuxer/mkvwriter.cc; do
em++ -c "${f}" -o "$(basename "${f}").cpp_0.o" \
-std=c++11 \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-Wno-extern-c-compat \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s WASM="${wasm}" \
-fPIC \
-I../.. -I../../.. || exit 1
done
emar rcs libwebm.a file_util.cc.cpp_0.o hdr_util.cc.cpp_0.o mkvparser.cc.cpp_0.o mkvreader.cc.cpp_0.o mkvmuxer.cc.cpp_0.o mkvmuxerutil.cc.cpp_0.o mkvwriter.cc.cpp_0.o
popd
}
build_webm 0 build/html5
build_webm 1 build/html5-wasm
popd
popd
- name: Collect artifacts
run: |
mkdir -p artifacts/videoplayer/lib/js-web artifacts/videoplayer/lib/wasm-web
cp libvpx/build-js-web/libvpx.a artifacts/videoplayer/lib/js-web/
cp libvpx/third_party/libwebm/build/html5/libwebm.a artifacts/videoplayer/lib/js-web/
cp libvpx/build-wasm-web/libvpx.a artifacts/videoplayer/lib/wasm-web/
cp libvpx/third_party/libwebm/build/html5-wasm/libwebm.a artifacts/videoplayer/lib/wasm-web/
test -f artifacts/videoplayer/lib/js-web/libvpx.a
test -f artifacts/videoplayer/lib/js-web/libwebm.a
test -f artifacts/videoplayer/lib/wasm-web/libvpx.a
test -f artifacts/videoplayer/lib/wasm-web/libwebm.a
- uses: actions/upload-artifact@v4
with:
name: libs-js
path: artifacts
windows:
name: Windows
runs-on: windows-2022
if: ${{ github.event_name == 'push' || inputs.build-windows != 'false' }}
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: >-
git
make
mingw-w64-x86_64-gcc
mingw-w64-i686-gcc
mingw-w64-x86_64-pkg-config
mingw-w64-i686-pkg-config
yasm
diffutils
- name: Fetch libvpx
run: git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 libvpx
- name: Build Windows libs
run: |
pushd libvpx
mkdir -p build-x86_64-win32
pushd build-x86_64-win32
CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar STRIP=x86_64-w64-mingw32-strip \
../configure \
--target=x86_64-win64-gcc \
--disable-examples \
--disable-unit-tests \
--disable-docs \
--disable-tools \
--enable-pic || exit 1
make -j"$(nproc)"
popd
mkdir -p build-x86-win32
pushd build-x86-win32
export PATH="/mingw32/bin:$PATH"
export PKG_CONFIG_PATH=/mingw32/lib/pkgconfig
CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-gcc-ar STRIP=i686-w64-mingw32-strip \
../configure \
--target=x86-win32-gcc \
--disable-examples \
--disable-unit-tests \
--disable-docs \
--disable-tools \
--enable-pic || exit 1
make -j"$(nproc)"
popd
popd
pushd libvpx/third_party/libwebm
# x86_64
OUT64="build/win/x86_64"
mkdir -p "${OUT64}"
pushd "${OUT64}"
for f in ../../common/file_util.cc ../../common/hdr_util.cc ../../mkvparser/mkvparser.cc ../../mkvparser/mkvreader.cc ../../mkvmuxer/mkvmuxer.cc ../../mkvmuxer/mkvmuxerutil.cc ../../mkvmuxer/mkvwriter.cc; do
x86_64-w64-mingw32-g++ -c "../${f}" -o "$(basename "${f}").cpp_0.o" \
-std=c++11 \
-static-libgcc -static-libstdc++ \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-Wno-extern-c-compat \
-I../../.. || exit 1
done
x86_64-w64-mingw32-gcc-ar rcs libwebm.a file_util.cc.cpp_0.o hdr_util.cc.cpp_0.o mkvparser.cc.cpp_0.o mkvreader.cc.cpp_0.o mkvmuxer.cc.cpp_0.o mkvmuxerutil.cc.cpp_0.o mkvwriter.cc.cpp_0.o
popd
# x86
OUT32="build/win/x86"
mkdir -p "${OUT32}"
pushd "${OUT32}"
for f in ../../common/file_util.cc ../../common/hdr_util.cc ../../mkvparser/mkvparser.cc ../../mkvparser/mkvreader.cc ../../mkvmuxer/mkvmuxer.cc ../../mkvmuxer/mkvmuxerutil.cc ../../mkvmuxer/mkvwriter.cc; do
i686-w64-mingw32-g++ -c "../${f}" -o "$(basename "${f}").cpp_0.o" \
-std=c++11 \
-static-libgcc -static-libstdc++ \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
-Wno-extern-c-compat \
-I../../.. || exit 1
done
i686-w64-mingw32-gcc-ar rcs libwebm.a file_util.cc.cpp_0.o hdr_util.cc.cpp_0.o mkvparser.cc.cpp_0.o mkvreader.cc.cpp_0.o mkvmuxer.cc.cpp_0.o mkvmuxerutil.cc.cpp_0.o mkvwriter.cc.cpp_0.o
popd
popd
- name: Collect artifacts
run: |
mkdir -p artifacts/videoplayer/lib/x86_64-win32 artifacts/videoplayer/lib/x86-win32
cp libvpx/build-x86_64-win32/libvpx.a artifacts/videoplayer/lib/x86_64-win32/libvpx.a
cp libvpx/build-x86-win32/libvpx.a artifacts/videoplayer/lib/x86-win32/libvpx.a
cp libvpx/third_party/libwebm/build/win/x86_64/libwebm.a artifacts/videoplayer/lib/x86_64-win32/
cp libvpx/third_party/libwebm/build/win/x86/libwebm.a artifacts/videoplayer/lib/x86-win32/
- uses: actions/upload-artifact@v4
with:
name: libs-windows
path: artifacts
update-branch:
name: Update branch with binaries
runs-on: ubuntu-22.04
needs:
- macos
- ios
- android
- html5
- windows
if: ${{ always() }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
continue-on-error: true
with:
path: downloaded-artifacts
- name: Stage new binaries
run: |
shopt -s globstar nullglob
REQUIRED=(
"videoplayer/lib/armv7-android/libvpx.a"
"videoplayer/lib/armv7-android/libwebm.a"
"videoplayer/lib/arm64-android/libvpx.a"
"videoplayer/lib/arm64-android/libwebm.a"
"videoplayer/lib/arm64-ios/libvpx.a"
"videoplayer/lib/arm64-ios/libwebm.a"
"videoplayer/lib/arm64-osx/libvpx.a"
"videoplayer/lib/arm64-osx/libwebm.a"
"videoplayer/lib/x86_64-osx/libvpx.a"
"videoplayer/lib/x86_64-osx/libwebm.a"
"videoplayer/lib/js-web/libvpx.a"
"videoplayer/lib/js-web/libwebm.a"
"videoplayer/lib/wasm-web/libvpx.a"
"videoplayer/lib/wasm-web/libwebm.a"
"videoplayer/lib/x86_64-win32/libvpx.a"
"videoplayer/lib/x86_64-win32/libwebm.a"
"videoplayer/lib/x86-win32/libvpx.a"
"videoplayer/lib/x86-win32/libwebm.a"
)
if compgen -G "downloaded-artifacts/*" > /dev/null; then
MISSING=()
for required in "${REQUIRED[@]}"; do
if ! find downloaded-artifacts -type f -path "*/${required}" -print -quit | grep -q .; then
MISSING+=("${required}")
fi
done
if [[ ${#MISSING[@]} -gt 0 ]]; then
echo "Missing artifacts:" >&2
printf ' - %s\n' "${MISSING[@]}" >&2
exit 1
fi
for archive in downloaded-artifacts/*; do
if [[ -d "${archive}/videoplayer/lib" ]]; then
rsync -a "${archive}/videoplayer/lib/" videoplayer/lib/
fi
done
else
echo "No artifacts to merge."
fi
- name: Commit and push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_BRANCH: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add videoplayer/lib
if git diff --cached --quiet; then
echo "No binary updates to commit."
exit 0
fi
git commit -m "videoplayer: update native libs"
git push origin "${TARGET_BRANCH}"
- name: Update headers
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_BRANCH: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
set -euo pipefail
if [[ ! -d "downloaded-artifacts" ]]; then
echo "No artifacts found; skipping header update."
exit 0
fi
TMP_ROOT="$(mktemp -d)"
git clone https://chromium.googlesource.com/webm/libvpx.git --branch "${LIBVPX_REF}" --depth 1 "${TMP_ROOT}/libvpx"
STAGED_INCLUDE="${TMP_ROOT}/staged-include"
mkdir -p "${STAGED_INCLUDE}"
STAGED_HAS_HEADERS=0
if [[ -d "${TMP_ROOT}/libvpx/vpx" ]]; then
rsync -a "${TMP_ROOT}/libvpx/vpx/" "${STAGED_INCLUDE}/vpx/"
STAGED_HAS_HEADERS=1
fi
if [[ -d "${TMP_ROOT}/libvpx/vpx_ports" ]]; then
rsync -a "${TMP_ROOT}/libvpx/vpx_ports/" "${STAGED_INCLUDE}/vpx_ports/"
STAGED_HAS_HEADERS=1
fi
if [[ "${STAGED_HAS_HEADERS}" == "0" ]]; then
echo "libvpx headers not found; aborting header update to avoid clearing includes."
exit 1
fi
if [[ -f "${TMP_ROOT}/libvpx/examples/webmdec.h" ]]; then
mkdir -p "${STAGED_INCLUDE}/webm"
cp "${TMP_ROOT}/libvpx/examples/webmdec.h" "${STAGED_INCLUDE}/webm/webmdec.h"
fi
ARTIFACT_CONFIG=$(find downloaded-artifacts -type f -path "*/videoplayer/include/vpx_config.h" -print -quit || true)
if [[ -z "${ARTIFACT_CONFIG}" && "${STAGED_HAS_HEADERS}" == "0" ]]; then
echo "No headers staged and no vpx_config.h found; skipping header update."
exit 0
fi
if [[ -n "${ARTIFACT_CONFIG}" ]]; then
cp "${ARTIFACT_CONFIG}" "${STAGED_INCLUDE}/vpx_config.h"
elif find "${TMP_ROOT}/libvpx" -maxdepth 1 -name "vpx_config.h" | grep -q .; then
cp "${TMP_ROOT}/libvpx"/vpx_config.h "${STAGED_INCLUDE}/vpx_config.h"
elif [[ -f "videoplayer/include/vpx_config.h" ]]; then
cp "videoplayer/include/vpx_config.h" "${STAGED_INCLUDE}/vpx_config.h"
else
echo "No vpx_config.h found; skipping header update."
exit 0
fi
find "${STAGED_INCLUDE}" -type f ! -name '*.h' -delete
rsync -a --delete "${STAGED_INCLUDE}/" videoplayer/include/
git add videoplayer/include
if git diff --cached --quiet; then
echo "No header updates to commit."
exit 0
fi
git commit -m "videoplayer: update headers"
git push origin "${TARGET_BRANCH}"