obs-streamFX/.github/workflows/main.yml

227 lines
9.0 KiB
YAML

# AUTOGENERATED COPYRIGHT HEADER START
# Copyright (C) 2019-2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
# AUTOGENERATED COPYRIGHT HEADER END
name: Build
on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
branches:
- '*'
concurrency:
group: build-${{ github.ref_name }}
cancel-in-progress: true
env:
CACHE_VERSION: "2024-01-25"
jobs:
build:
strategy:
fail-fast: false
matrix:
runner: [ "windows-2022", "macos-12", "ubuntu-22.04" ]
compiler: [ "MSVC", "GCC-12", "Clang-17", "AppleClang" ]
include:
- runner: "windows-2022"
compiler: "MSVC"
platform: "windows"
name: "Windows"
CMAKE_SYSTEM_VERSION: "10.0.20348.0"
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_GENERATOR_PLATFORM: "x64"
- runner: "macos-12"
compiler: "AppleClang"
platform: "macos"
name: "MacOS"
CMAKE_GENERATOR: "Xcode"
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
CMAKE_OSX_ARCHITECTURES: "x86_64;arm64"
- runner: "ubuntu-22.04"
compiler: "GCC-12"
platform: "ubuntu"
name: "Ubuntu 22.04"
CMAKE_GENERATOR: "Ninja Multi-Config"
- runner: "ubuntu-22.04"
compiler: "Clang-17"
platform: "ubuntu"
name: "Ubuntu 22.04 (Clang)"
CMAKE_GENERATOR: "Ninja Multi-Config"
exclude:
- runner: "windows-2022"
compiler: "GCC-12"
- runner: "windows-2022"
compiler: "Clang-17"
- runner: "windows-2022"
compiler: "AppleClang"
- runner: "macos-12"
compiler: "MSVC"
- runner: "macos-12"
compiler: "GCC-12"
- runner: "macos-12"
compiler: "Clang-17"
- runner: "ubuntu-22.04"
compiler: "MSVC"
- runner: "ubuntu-22.04"
compiler: "AppleClang"
name: "${{ matrix.name}} (${{ matrix.compiler}})"
runs-on: "${{ matrix.runner }}"
env:
CMAKE_BUILD_TYPE: "RelWithDebInfo"
CMAKE_GENERATOR: "${{ matrix.CMAKE_GENERATOR }}"
CMAKE_GENERATOR_PLATFORM: "${{ matrix.CMAKE_GENERATOR_PLATFORM }}"
CMAKE_SYSTEM_VERSION: "${{ matrix.CMAKE_SYSTEM_VERSION }}"
CMAKE_OSX_DEPLOYMENT_TARGET: "${{ matrix.CMAKE_OSX_DEPLOYMENT_TARGET }}"
CMAKE_OSX_ARCHITECTURES: "${{ matrix.CMAKE_OSX_ARCHITECTURES }}"
steps:
- name: "Install Compiler"
if: ${{ matrix.platform == 'linux' }}
shell: bash
run: |
# Install the appropriate compiler
IFS=$'-' compiler=($(echo "${{ matrix.compiler }}")) # ToDo: Can this be done without invoking a sub-shell?
echo "Installing '${compiler[0]}' version ${compiler[1]}..."
if [[ "${compiler[0]}" == "GCC" ]]; then
sudo apt-get install binutils gcc-${compiler[1]} g++-${compiler[1]}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${compiler[1]} 800 --slave /usr/bin/g++ g++ /usr/bin/g++-${compiler[1]}
echo "CMAKE_C_COMPILER=gcc-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER=g++-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_LINKER=gold" >> "$GITHUB_ENV"
elif [[ "${compiler[0]}" == "Clang" ]]; then
curl -jLo /tmp/llvm.sh "https://apt.llvm.org/llvm.sh"
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh ${compiler[1]} all
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${compiler[1]} 800
echo "CMAKE_C_COMPILER=clang-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER=clang++-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_LINKER=ld.lld-${compiler[1]}" >> "$GITHUB_ENV"
else
echo "Unknown Compiler"
exit 1
fi
- name: "Clone"
uses: "actions/checkout@v4"
with:
fetch-depth: 0
fetch-tags: true
- name: "Fetch"
shell: bash
run: |
./tools/build.sh fetch
- name: "Gather"
shell: bash
run: |
echo "OBS_VERSION=$(cd third-party/obs-studio/ && git describe --tags --long --abbrev=8 HEAD)" >> "${GITHUB_ENV}"
- name: "Patch"
shell: bash
run: |
./tools/build.sh patch
- name: "Prerequisites"
shell: bash
run: |
./tools/build.sh prerequisites
- name: "libOBS: Restore Cache"
id: libobs
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/third-party/obs-studio/.deps
${{ github.workspace }}/third-party/obs-studio/build/install
key: "${{ secrets.CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ env.OBS_VERSION }}-${{ matrix.compiler }}-libobs"
- name: "libOBS"
if: ${{ (steps.libobs.outputs.cache-hit != 'true') }}
shell: bash
run: |
./tools/build.sh libobs
- name: "libOBS: Save Cache"
if: ${{ (steps.libobs.outputs.cache-hit != 'true') }}
uses: actions/cache/save@v3
with:
path: |
${{ github.workspace }}/third-party/obs-studio/.deps
${{ github.workspace }}/third-party/obs-studio/build/install
key: "${{ secrets.CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ env.OBS_VERSION }}-${{ matrix.compiler }}-libobs"
- name: "Build: Restore Cache"
if: ${{ (steps.libobs.outputs.cache-hit == 'true') && (startsWith(github.ref, 'refs/heads/')) }}
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/build
key: "${{ secrets.CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ env.OBS_VERSION }}-${{ matrix.compiler }}-build"
- name: "Build"
shell: bash
run: |
./tools/build.sh configure \
--build "${{ github.workspace }}/build" \
--install "${{ github.workspace }}/build/install" \
--package "${{ github.workspace }}/build/package" \
--package-name "StreamFX ${{ matrix.name }} (for OBS Studio v${{ env.OBS_VERSION }}) v"
_r=$?; if [[ $_r != 0 ]]; then exit "$_r"; fi
./tools/build.sh build \
--build "${{ github.workspace }}/build"
_r=$?; if [[ $_r != 0 ]]; then exit "$_r"; fi
echo "STREAMFX_VERSION=$(LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 grep -hoPe "[0-9]+\.[0-9]+\.[0-9]+(|[abc][0-9]+)-g[a-fA-F0-9]+" "${{ github.workspace }}/build/generated/version.hpp")" >> "${GITHUB_ENV}"
- name: "Build: Save Cache"
if: ${{ startsWith(github.ref, 'refs/heads/') }}
uses: actions/cache/save@v3
with:
path: |
${{ github.workspace }}/build
key: "${{ secrets.CACHE_VERSION }}-${{ env.CACHE_VERSION }}-${{ env.OBS_VERSION }}-${{ matrix.compiler }}-build"
- name: "Install"
shell: bash
run: |
./tools/build.sh install \
--build "${{ github.workspace }}/build"
- name: "Packaging: Install InnoSetup"
if: startsWith( matrix.runner, 'windows' )
run: |
curl "-kL" "https://cdn.xaymar.com/ci/innosetup-6.2.1.exe" "-f" "--retry" "5" "-o" "inno.exe"
.\inno.exe /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART
- name: 'Packaging: Install Packages'
continue-on-error: true
if: startsWith( matrix.runner, 'macos' )
shell: bash
run: |
curl -kL https://cdn.xaymar.com/ci/Packages-1.2.10.dmg -f --retry 5 -o "Packages.dmg"
sudo hdiutil attach ./Packages.dmg
pushd /Volumes/Packages*
sudo installer -pkg ./Install\ Packages.pkg -target /
- name: "Packaging"
if: startsWith( matrix.runner, 'windows' )
shell: cmd
run: |
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /V10 ".\build\installer.iss"
- name: "Packaging"
if: startsWith( matrix.runner, 'ubuntu' )
shell: bash
run: |
mkdir "${{ github.workspace }}/build/package"
cmake --build "${{ github.workspace }}/build" --config RelWithDebInfo --target PACKAGE
- name: "Packaging"
if: startsWith( matrix.runner, 'macos' )
shell: bash
run: |
packagesbuild "${{ github.workspace }}/build/installer.pkgproj"
- name: "Artifacts"
uses: actions/upload-artifact@v4
with:
name: "StreamFX ${{ matrix.name }} (for OBS Studio v${{ env.OBS_VERSION }}) v${{ env.STREAMFX_VERSION }}"
path: "${{ github.workspace }}/build/package"
if-no-files-found: error
compression-level: 0