Skip to content

Commit 7aa1f66

Browse files
authored
ci: create main.yml
0 parents  commit 7aa1f66

File tree

1 file changed

+386
-0
lines changed

1 file changed

+386
-0
lines changed

.github/workflows/main.yml

+386
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,386 @@
1+
name: Build
2+
3+
on:
4+
# Allows you to run this workflow manually from the Actions tab
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: build-${{ github.ref_name }}
9+
cancel-in-progress: true
10+
11+
env:
12+
CACHE_VERSION: "2022-12-02"
13+
14+
jobs:
15+
build:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
runner: [ "windows-2022", "macos-12", "ubuntu-22.04", "ubuntu-20.04" ]
20+
qt: [ 5, 6 ]
21+
generator: [ "MSVC", "GCC", "Clang" ]
22+
exclude:
23+
- runner: windows-2022
24+
generator: GCC
25+
- runner: windows-2022
26+
generator: Clang
27+
- runner: windows-2022
28+
qt: 5
29+
- runner: macos-12
30+
generator: MSVC
31+
- runner: macos-12
32+
generator: GCC
33+
- runner: macos-12
34+
qt: 5
35+
- runner: ubuntu-22.04
36+
generator: MSVC
37+
- runner: ubuntu-22.04
38+
qt: 5
39+
- runner: ubuntu-20.04
40+
generator: MSVC
41+
- runner: ubuntu-20.04
42+
qt: 6
43+
include:
44+
# Windows supports MSVC
45+
- runner: windows-2022
46+
name: "Windows"
47+
package_name: "windows"
48+
CMAKE_SYSTEM_VERSION: "10.0.20348.0"
49+
CMAKE_GENERATOR: "Visual Studio 17 2022"
50+
CMAKE_GENERATOR_PLATFORM: "x64"
51+
52+
# MacOS supports Clang
53+
- runner: macos-12
54+
name: "MacOS"
55+
package_name: "macos"
56+
CMAKE_GENERATOR: "Xcode"
57+
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
58+
CMAKE_OSX_ARCHITECTURES: "x86_64;arm64"
59+
60+
# Ubuntu needs version-specific binaries
61+
- runner: ubuntu-22.04
62+
name: "Ubuntu 22.04"
63+
package_name: "ubuntu-22"
64+
CMAKE_GENERATOR: "Ninja"
65+
- runner: ubuntu-20.04
66+
name: "Ubuntu 20.04"
67+
package_name: "ubuntu-20"
68+
CMAKE_GENERATOR: "Ninja"
69+
70+
runs-on: "${{ matrix.runner }}"
71+
name: "${{ matrix.name }} (${{ matrix.generator }}, Qt${{ matrix.qt }})"
72+
env:
73+
CMAKE_GENERATOR: "${{ matrix.CMAKE_GENERATOR }}"
74+
CMAKE_GENERATOR_PLATFORM: "${{ matrix.CMAKE_GENERATOR_PLATFORM }}"
75+
CMAKE_GENERATOR_TOOLSET: "${{ matrix.CMAKE_GENERATOR_TOOLSET }}"
76+
CMAKE_SYSTEM_VERSION: "${{ matrix.CMAKE_SYSTEM_VERSION }}"
77+
CMAKE_OSX_DEPLOYMENT_TARGET: "${{ matrix.CMAKE_OSX_DEPLOYMENT_TARGET }}"
78+
CMAKE_OSX_ARCHITECTURES: "${{ matrix.CMAKE_OSX_ARCHITECTURES }}"
79+
steps:
80+
- name: "Clone"
81+
uses: actions/checkout@v3
82+
with:
83+
repository: "Xaymar/obs-StreamFX"
84+
submodules: recursive
85+
fetch-depth: 0
86+
87+
- name: 'Get Latest Tag'
88+
id: get-latest-tag
89+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
90+
91+
- name: "Checkout Latest Tag"
92+
run: |
93+
git checkout ${{ steps.get-latest-tag.outputs.tag }}
94+
95+
- name: "Install Build Tools (Ubuntu)"
96+
if: startsWith( matrix.runner, 'ubuntu' )
97+
shell: bash
98+
run: |
99+
sudo apt-get -qq update
100+
sudo apt-get purge libjpeg9-dev:amd64 libjpeg8-dev:amd64 libjpeg-turbo8-dev:amd64
101+
sudo apt-get install \
102+
build-essential \
103+
checkinstall \
104+
pkg-config \
105+
cmake \
106+
ninja-build \
107+
git \
108+
gcc-10 g++10
109+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 800 --slave /usr/bin/g++ g++ /usr/bin/g++-10
110+
111+
- name: "Install LLVM/Clang (Windows)"
112+
if: startsWith( matrix.runner, 'windows' )
113+
run: |
114+
curl "-kL" "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.4/LLVM-14.0.4-win64.exe" "-f" "--retry" "5" "-o" "llvm.exe"
115+
7z x -y -o"C:\Program Files\LLVM" llvm.exe "bin" "include" "lib" "libexec" "share" "Uninstall.exe"
116+
echo "CLANG_PATH=\"C:\\Program Files\\LLVM\\bin\"" >> "${GITHUB_ENV}"
117+
- name: "Install LLVM/Clang (Ubuntu)"
118+
if: startsWith( matrix.runner, 'ubuntu' )
119+
shell: bash
120+
run: |
121+
curl -jLo /tmp/llvm.sh "https://apt.llvm.org/llvm.sh"
122+
chmod +x /tmp/llvm.sh
123+
sudo /tmp/llvm.sh 14 all
124+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 800
125+
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-14 800
126+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 800
127+
sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-14 800
128+
sudo update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-14 800
129+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 800
130+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 800
131+
echo "CLANG_PATH=/usr/bin" >> "${GITHUB_ENV}"
132+
- name: "Install LLVM/Clang (MacOS)"
133+
if: startsWith( matrix.runner, 'macos' )
134+
shell: bash
135+
run: |
136+
brew install llvm@14
137+
LLVM_LOC=$(brew --prefix llvm@14)
138+
echo "CLANG_PATH=${LLVM_LOC}/bin/" >> "${GITHUB_ENV}"
139+
140+
- name: "Install InnoSetup (Windows)"
141+
if: startsWith( matrix.runner, 'windows' )
142+
run: |
143+
curl "-kL" "https://cdn.xaymar.com/ci/innosetup-6.2.1.exe" "-f" "--retry" "5" "-o" "inno.exe"
144+
.\inno.exe /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART
145+
146+
- name: 'Install Packages (MacOS)'
147+
if: startsWith( matrix.runner, 'macos' )
148+
shell: bash
149+
run: |
150+
curl -kL https://cdn.xaymar.com/ci/Packages-1.2.10.dmg -f --retry 5 -o "Packages.dmg"
151+
sudo hdiutil attach ./Packages.dmg
152+
pushd /Volumes/Packages*
153+
sudo installer -pkg ./Install\ Packages.pkg -target /
154+
155+
- name: "Setup build Tools and gather Information"
156+
id: info
157+
shell: bash
158+
run: |
159+
# Dependency Versioning
160+
if [[ "${{ matrix.runner }}" = windows* ]]; then
161+
if [[ -f "${{ github.workspace }}/third-party/DEPS_VERSION_WIN" ]]; then
162+
echo "obs_deps_version=$(cat "${{ github.workspace }}/third-party/DEPS_VERSION_WIN")" >> $GITHUB_ENV
163+
else
164+
[[ $(cat "${{ github.workspace }}/third-party/obs-studio/.github/workflows/main.yml") =~ DEPS_VERSION_WIN:\ \'([0-9a-zA-Z\-]+)\' ]]
165+
echo "obs_deps_version=${BASH_REMATCH[1]}" >> $GITHUB_ENV
166+
fi
167+
elif [[ "${{ matrix.runner }}" = macos* ]]; then
168+
if [[ -f "${{ github.workspace }}/third-party/DEPS_VERSION_MAC" ]]; then
169+
echo "obs_deps_version=$(cat "${{ github.workspace }}/third-party/DEPS_VERSION_MAC")" >> $GITHUB_ENV
170+
else
171+
[[ $(cat "${{ github.workspace }}/third-party/obs-studio/.github/workflows/main.yml") =~ DEPS_VERSION_MAC:\ \'([0-9a-zA-Z\-]+)\' ]]
172+
echo "obs_deps_version=${BASH_REMATCH[1]}" >> $GITHUB_ENV
173+
fi
174+
else
175+
echo "obs_deps_version=BADVALUE" >> $GITHUB_ENV
176+
fi
177+
echo "obs_version::$(cd "${{ github.workspace }}/third-party/obs-studio" && git describe --tags --long)"
178+
179+
# CMake Flags
180+
if [[ "${{ matrix.CMAKE_GENERATOR }}" != "" ]]; then
181+
echo "cmake_generator=-G \"${{ matrix.CMAKE_GENERATOR }}\"" >> $GITHUB_ENV
182+
fi
183+
if [[ "${{ matrix.CMAKE_GENERATOR_TOOLSET }}" != "" ]]; then
184+
echo "cmake_generator_toolset=-T \"${{ matrix.CMAKE_GENERATOR_TOOLSET }}\"" >> $GITHUB_ENV
185+
fi
186+
if [[ "${{ matrix.CMAKE_GENERATOR_PLATFORM }}" != "" ]]; then
187+
echo "cmake_generator_platform=-A \"${{ matrix.CMAKE_GENERATOR_PLATFORM }}\"" >> $GITHUB_ENV
188+
fi
189+
190+
# Compiler Setup
191+
if [[ "${{ matrix.runner }}" = ubuntu* ]]; then
192+
if [[ "${{ matrix.generator }}" = "GCC" ]]; then
193+
echo "CC=gcc-10" >> "${GITHUB_ENV}"
194+
echo "CXX=g++-10" >> "${GITHUB_ENV}"
195+
echo "LD=ld" >> "${GITHUB_ENV}"
196+
elif [[ "${{ matrix.generator }}" = "Clang" ]]; then
197+
echo "CC=clang-14" >> "${GITHUB_ENV}"
198+
echo "CXX=clang++-14" >> "${GITHUB_ENV}"
199+
echo "LD=lld" >> "${GITHUB_ENV}"
200+
fi
201+
fi
202+
203+
- name: "Dependency: Qt (Cache)"
204+
id: qt-cache
205+
if: ${{ ! startsWith( matrix.runner, 'ubuntu' ) }}
206+
uses: actions/cache@v3
207+
with:
208+
path: "${{ github.workspace }}/build/qt"
209+
key: "${{ matrix.runner }}-obsdeps${{ env.obs_deps_version }}-qt${{ matrix.qt }}-${{ env.CACHE_VERSION }}"
210+
- name: "Dependency: Qt "
211+
id: qt
212+
if: ${{ startsWith( matrix.runner, 'ubuntu' ) || (steps.qt-cache.outputs.cache-hit != 'true') }}
213+
shell: bash
214+
run: |
215+
if [[ "${{ matrix.runner }}" = windows* ]]; then
216+
curl --retry 5 --retry-delay 30 -jLo /tmp/qt.zip "https://github.com/obsproject/obs-deps/releases/download/${{ env.obs_deps_version }}/windows-deps-qt${{ matrix.qt }}-${{ env.obs_deps_version }}-x64.zip"
217+
if [[ ! -f "${{ github.workspace }}/build/qt" ]]; then mkdir -p "${{ github.workspace }}/build/qt"; fi
218+
7z x -y -o"${{ github.workspace }}/build/qt" -- "/tmp/qt.zip"
219+
elif [[ "${{ matrix.runner }}" = macos* ]]; then
220+
curl --retry 5 --retry-delay 30 -jLo /tmp/qt.tar.xz "https://github.com/obsproject/obs-deps/releases/download/${{ env.obs_deps_version }}/macos-deps-qt${{ matrix.qt }}-${{ env.obs_deps_version }}-universal.tar.xz"
221+
if [[ ! -f "${{ github.workspace }}/build/qt" ]]; then mkdir -p "${{ github.workspace }}/build/qt"; fi
222+
tar -xvf "/tmp/qt.tar.xz" -C "${{ github.workspace }}/build/qt"
223+
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
224+
if [[ ${{ matrix.qt }} -eq 5 ]]; then
225+
sudo apt-get -y install -V \
226+
qtbase5-dev qtbase5-private-dev libqt5svg5-dev
227+
elif [[ ${{ matrix.qt }} -eq 6 ]]; then
228+
sudo apt-get -y install -V \
229+
qt6-base-dev qt6-base-private-dev libqt6svg6-dev libgles2-mesa-dev libegl1-mesa-dev libgl1-mesa-dev
230+
fi
231+
fi
232+
233+
- name: "Dependency: OBS Dependencies (FFmpeg, CURL, ...) (Cache)"
234+
id: obsdeps-cache
235+
if: ${{ ! startsWith( matrix.runner, 'ubuntu' ) }}
236+
uses: actions/cache@v3
237+
with:
238+
path: "${{ github.workspace }}/build/obsdeps"
239+
key: "${{ matrix.runner }}-obsdeps${{ env.obs_deps_version }}-${{ env.CACHE_VERSION }}"
240+
- name: "Dependency: OBS Dependencies (FFmpeg, CURL, ...)"
241+
id: obsdeps
242+
if: ${{ startsWith( matrix.runner, 'ubuntu' ) || (steps.obsdeps-cache.outputs.cache-hit != 'true') }}
243+
shell: bash
244+
run: |
245+
if [[ "${{ matrix.runner }}" = windows* ]]; then
246+
curl --retry 5 --retry-delay 30 -jLo /tmp/obsdeps.zip "https://github.com/obsproject/obs-deps/releases/download/${{ env.obs_deps_version }}/windows-deps-${{ env.obs_deps_version }}-x64.zip"
247+
if [[ ! -f "${{ github.workspace }}/build/obsdeps" ]]; then mkdir -p "${{ github.workspace }}/build/obsdeps"; fi
248+
7z x -y -o"${{ github.workspace }}/build/obsdeps" -- "/tmp/obsdeps.zip"
249+
elif [[ "${{ matrix.runner }}" = macos* ]]; then
250+
curl --retry 5 --retry-delay 30 -jLo /tmp/obsdeps.tar.xz "https://github.com/obsproject/obs-deps/releases/download/${{ env.obs_deps_version }}/macos-deps-${{ env.obs_deps_version }}-universal.tar.xz"
251+
if [[ ! -f "${{ github.workspace }}/build/obsdeps" ]]; then mkdir -p "${{ github.workspace }}/build/obsdeps"; fi
252+
tar -xvf "/tmp/obsdeps.tar.xz" -C "${{ github.workspace }}/build/obsdeps"
253+
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
254+
sudo apt-get -y install -V \
255+
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev \
256+
libcurl4-openssl-dev
257+
fi
258+
259+
- name: "Dependency: OBS Libraries (Cache)"
260+
id: obs-cache
261+
uses: actions/cache@v3
262+
with:
263+
path: "${{ github.workspace }}/build/obs"
264+
key: "${{ matrix.runner }}-${{ matrix.generator }}-obs${{ env.obs_version }}-obsdeps${{ env.obs_deps_version }}-qt${{ matrix.qt }}-${{ env.CACHE_VERSION }}"
265+
- name: "Dependency: OBS Libraries"
266+
id: obs
267+
if: ${{ steps.obs-cache.outputs.cache-hit != 'true' }}
268+
shell: bash
269+
env:
270+
CMAKE_BUILD_TYPE: "Release"
271+
run: |
272+
# Extra requirements by libobs on Linux.
273+
if [[ "${{ matrix.runner }}" = ubuntu* ]]; then
274+
sudo apt-get install \
275+
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev \
276+
libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev libluajit-5.1-dev python3-dev \
277+
libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev libxcomposite-dev libxinerama-dev \
278+
libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev swig libcmocka-dev libxss-dev libglvnd-dev libgles2-mesa \
279+
libgles2-mesa-dev libwayland-dev \
280+
libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev libpulse-dev \
281+
libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev libdrm-dev
282+
fi
283+
cmake \
284+
-S "${{ github.workspace }}/third-party/obs-studio" \
285+
-B "${{ github.workspace }}/build/obs" \
286+
${{ env.cmake_generator }} \
287+
${{ env.cmake_generator_toolset }} \
288+
${{ env.cmake_generator_platform }} \
289+
-DCMAKE_C_COMPILER="${{ env.CC }}" \
290+
-DCMAKE_CXX_COMPILER="${{ env.CXX }}" \
291+
-DCMAKE_LINKER="${{ env.LD }}" \
292+
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.CMAKE_OSX_ARCHITECTURES }}" \
293+
-DCMAKE_OSX_DEPLOYMENT_TARGET="${{ matrix.CMAKE_OSX_DEPLOYMENT_TARGET }}" \
294+
-DCMAKE_SYSTEM_VERSION="${{ matrix.CMAKE_SYSTEM_VERSION }}" \
295+
-DCMAKE_BUILD_TYPE="${{ env.CMAKE_BUILD_TYPE }}" \
296+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/build/obs/install" \
297+
-DENABLE_PLUGINS=OFF \
298+
-DENABLE_UI=OFF \
299+
-DENABLE_SCRIPTING=OFF \
300+
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/build/obsdeps;${{ github.workspace }}/build/qt"
301+
cmake \
302+
--build "${{ github.workspace }}/build/obs" \
303+
--config Release \
304+
--target obs-frontend-api
305+
cmake \
306+
--install "${{ github.workspace }}/build/obs" \
307+
--config Release \
308+
--component obs_libraries
309+
310+
- name: "Configure (Cache)"
311+
if: ${{ ! startsWith( github.ref, 'refs/tags/' ) }}
312+
id: streamfx-cache
313+
uses: actions/cache@v3
314+
with:
315+
path: "${{ github.workspace }}/build/ci"
316+
key: "${{ matrix.runner }}-${{ matrix.generator }}-${{ github.ref_name }}-obs${{ env.obs_version }}-obsdeps${{ env.obs_deps_version }}-qt${{ matrix.qt }}-${{ env.CACHE_VERSION }}"
317+
restore-keys: |
318+
"${{ matrix.runner }}-${{ matrix.generator }}-${{ github.ref_name }}-obs${{ env.obs_version }}-obsdeps${{ env.obs_deps_version }}-qt${{ matrix.qt }}-${{ env.CACHE_VERSION }}"
319+
"${{ matrix.runner }}-${{ matrix.generator }}-main-obs${{ env.obs_version }}-obsdeps${{ env.obs_deps_version }}-qt${{ matrix.qt }}-${{ env.CACHE_VERSION }}"
320+
- name: "Configure"
321+
continue-on-error: true
322+
shell: bash
323+
run: |
324+
cmake \
325+
-S "${{ github.workspace }}" \
326+
-B "${{ github.workspace }}/build/ci" \
327+
${{ env.cmake_generator }} \
328+
${{ env.cmake_generator_toolset }} \
329+
${{ env.cmake_generator_platform }} \
330+
-DCMAKE_C_COMPILER="${{ env.CC }}" \
331+
-DCMAKE_CXX_COMPILER="${{ env.CXX }}" \
332+
-DCMAKE_LINKER="${{ env.LD }}" \
333+
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.CMAKE_OSX_ARCHITECTURES }}" \
334+
-DCMAKE_OSX_DEPLOYMENT_TARGET="${{ matrix.CMAKE_OSX_DEPLOYMENT_TARGET }}" \
335+
-DCMAKE_SYSTEM_VERSION="${{ matrix.CMAKE_SYSTEM_VERSION }}" \
336+
-DCMAKE_BUILD_TYPE="${{ env.CMAKE_BUILD_TYPE }}" \
337+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/build/ci/install" \
338+
-DPACKAGE_NAME="streamfx-${{ matrix.package_name }}" \
339+
-DPACKAGE_PREFIX="${{ github.workspace }}/build/package" \
340+
-DENABLE_CLANG=TRUE -DCLANG_PATH="${{ env.CLANG_PATH }}" \
341+
-Dlibobs_DIR="${{ github.workspace }}/build/obs/install" \
342+
-DQt_DIR="${{ github.workspace }}/build/qt" \
343+
-DFFmpeg_DIR="${{ github.workspace }}/build/obsdeps" \
344+
-DCURL_DIR="${{ github.workspace }}/build/obsdeps"
345+
- name: "Build"
346+
shell: bash
347+
env:
348+
CMAKE_BUILD_TYPE: "Release"
349+
run: |
350+
if [[ "${{ matrix.runner }}" = windows* ]]; then
351+
cmake --build "build/ci" --config ${{ env.CMAKE_BUILD_TYPE }} --target install
352+
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
353+
cmake --build "build/ci" --config ${{ env.CMAKE_BUILD_TYPE }} --target install/strip
354+
elif [[ "${{ matrix.runner }}" = macos* ]]; then
355+
cmake --build "build/ci" --config ${{ env.CMAKE_BUILD_TYPE }} --target install
356+
fi
357+
358+
- name: "Packaging"
359+
shell: bash
360+
run: |
361+
mkdir "${{ github.workspace }}/build/package"
362+
cmake --build "${{ github.workspace }}/build/ci" --config Release --target PACKAGE_7Z
363+
- name: "Packaging (Windows)"
364+
if: startsWith( matrix.runner, 'windows' )
365+
shell: cmd
366+
run: |
367+
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /V10 ".\build\ci\installer.iss"
368+
- name: "Packaging (MacOS)"
369+
if: startsWith( matrix.runner, 'macos' )
370+
shell: bash
371+
run: |
372+
packagesbuild "${{ github.workspace }}/build/ci/installer.pkgproj"
373+
374+
- name: "Artifacts"
375+
uses: actions/upload-artifact@v1
376+
with:
377+
name: "${{ matrix.runner }}-${{ matrix.generator }}-qt${{ matrix.qt }}"
378+
path: "${{ github.workspace }}/build/package"
379+
380+
- name: "Validate clang-format"
381+
shell: bash
382+
run: |
383+
cmake --build "${{ github.workspace }}/build/ci" --config Release --target clang-format
384+
git --no-pager diff --patch --minimal HEAD --
385+
git update-index --refresh
386+
git diff-index --quiet HEAD --

0 commit comments

Comments
 (0)