Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Create a .pkg distribution automatically with GitHub Actions (#82)
Browse files Browse the repository at this point in the history
* Initial version of potential GitHub actions pkg build

* Fix working directory for package script

* Fix path to .so file

* Add step to install packagesbuild

* Dont check for packagesbuild we know it's not installed

* Point installer to correct path for .so file

* Don't forget locales

* Fix format of recalling secrets

* Try to bundle the DAL plugin as well

* Force re-signature of the DAL plugin

* Separate workflow for build from release

* s/pull-request/pull_request/
  • Loading branch information
johnboiles committed May 12, 2020
1 parent 77d9dcb commit 5db91b4
Show file tree
Hide file tree
Showing 10 changed files with 997 additions and 15 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,46 @@
name: Build

This comment has been minimized.


on:
pull_request:

jobs:
build:
runs-on: macos-latest

steps:
- name: Checkout obs-studio
uses: actions/checkout@v2
with:
repository: obsproject/obs-studio
path: obs-studio
submodules: recursive
ref: 25.0.8

- name: Checkout obs-mac-virtualcam
uses: actions/checkout@v2
with:
path: obs-mac-virtualcam

- name: Install OBS deps
run: |
brew install FFmpeg x264 Qt5 cmake mbedtls swig
- name: Build OBS
run: |
mkdir obs-studio/build
cd obs-studio/build
export QTDIR=/usr/local/opt/qt
cmake ..
make -j
- name: Build the plugin
run: |
mkdir obs-mac-virtualcam/build
cd obs-mac-virtualcam/build
cmake -DLIBOBS_INCLUDE_DIR:STRING=$GITHUB_WORKSPACE/obs-studio/libobs \
-DLIBOBS_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/libobs/libobs.dylib \
-DOBS_FRONTEND_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/UI/obs-frontend-api/libobs-frontend-api.dylib \
-DQTDIR:STRING=/usr/local/opt/qt ..
make -j
45 changes: 31 additions & 14 deletions .github/workflows/release.yml
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- master
- pkg-build
tags:
- "v*"

jobs:
build:
Expand All @@ -16,7 +19,7 @@ jobs:
repository: obsproject/obs-studio
path: obs-studio
submodules: recursive
ref: 25.0.7
ref: 25.0.8

- name: Checkout obs-mac-virtualcam
uses: actions/checkout@v2
Expand All @@ -41,7 +44,10 @@ jobs:
mkdir obs-mac-virtualcam/build
cd obs-mac-virtualcam/build
cmake -DLIBOBS_INCLUDE_DIR:STRING=$GITHUB_WORKSPACE/obs-studio/libobs -DLIBOBS_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/libobs/libobs.dylib -DOBS_FRONTEND_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/UI/obs-frontend-api/libobs-frontend-api.dylib -DQTDIR:STRING=/usr/local/opt/qt ..
cmake -DLIBOBS_INCLUDE_DIR:STRING=$GITHUB_WORKSPACE/obs-studio/libobs \
-DLIBOBS_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/libobs/libobs.dylib \
-DOBS_FRONTEND_LIB:STRING=$GITHUB_WORKSPACE/obs-studio/build/UI/obs-frontend-api/libobs-frontend-api.dylib \
-DQTDIR:STRING=/usr/local/opt/qt ..
make -j
- name: Fix runtime QT deps
Expand All @@ -55,25 +61,36 @@ jobs:
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore \
obs-mac-virtualcam/build/src/obs-plugin/obs-mac-virtualcam.so
- name: Install Apple certificates
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}

- name: Package Plugin
run: ./ci/macos/package-macos.sh
working-directory: ./obs-mac-virtualcam
env:
RELEASE_MODE: "True"
CODE_SIGNING_IDENTITY: John Boiles
INSTALLER_SIGNING_IDENTITY: John Boiles
AC_USERNAME: ${{ secrets.NOTARAZATION_USERNAME }}
AC_PASSWORD: ${{ secrets.NOTARIZATION_PASSWORD }}
AC_PROVIDER_SHORTNAME: ${{ secrets.NOTARIZATION_PROVIDER_SHORTNAME }}

- name: Copy artifacts
run: |
mkdir -p artifacts/dal-plugin
mkdir -p artifacts/obs-plugin
mkdir -p artifacts
cp -r obs-mac-virtualcam/build/src/dal-plugin/obs-mac-virtualcam.plugin artifacts/dal-plugin/
cp obs-mac-virtualcam/build/src/obs-plugin/obs-mac-virtualcam.so artifacts/obs-plugin/
cp -r obs-mac-virtualcam/build/src/dal-plugin/obs-mac-virtualcam.plugin artifacts/
cp obs-mac-virtualcam/build/src/obs-plugin/obs-mac-virtualcam.so artifacts/
- uses: actions/upload-artifact@v1
with:
name: obs-mac-virtualcam
name: raw-plugins
path: artifacts

- uses: actions/upload-artifact@v1
with:
name: obs-mac-virtualcam-dal-plugin
path: artifacts/dal-plugin

- uses: actions/upload-artifact@v1
with:
name: obs-mac-virtualcam-obs-plugin
path: artifacts/obs-plugin
name: pkg-installer
path: obs-mac-virtualcam/release
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
build/
xcode/
.DS_Store
*.generated.*
/installer/Output/
19 changes: 18 additions & 1 deletion CMakeLists.txt
@@ -1,8 +1,25 @@
cmake_minimum_required(VERSION 3.17)
project(mac-virtualcam)

project(obs-mac-virtualcam VERSION 1.0.0)
set(PLUGIN_AUTHOR "John Boiles")
set(MACOS_BUNDLEID "com.johnboiles.obs-mac-virtualcam")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11")

configure_file(
installer/installer-macOS.pkgproj.in
../installer/installer-macOS.generated.pkgproj
)

configure_file(
ci/ci_includes.sh.in
../ci/ci_includes.generated.sh
)
configure_file(
ci/ci_includes.cmd.in
../ci/ci_includes.generated.cmd
)

add_subdirectory(src/obs-plugin)
add_subdirectory(src/dal-plugin)
2 changes: 2 additions & 0 deletions ci/ci_includes.cmd.in
@@ -0,0 +1,2 @@
set PluginName=@CMAKE_PROJECT_NAME@
set PluginVersion=@CMAKE_PROJECT_VERSION@
3 changes: 3 additions & 0 deletions ci/ci_includes.sh.in
@@ -0,0 +1,3 @@
PLUGIN_NAME="@CMAKE_PROJECT_NAME@"
PLUGIN_VERSION="@CMAKE_PROJECT_VERSION@"
MACOS_BUNDLEID="@MACOS_BUNDLEID@"
Binary file added ci/macos/certs.p12
Binary file not shown.
102 changes: 102 additions & 0 deletions ci/macos/package-macos.sh
@@ -0,0 +1,102 @@
#!/bin/bash

set -e

script_dir=$(dirname "$0")
source "$script_dir/../ci_includes.generated.sh"

OSTYPE=$(uname)

if [ "${OSTYPE}" != "Darwin" ]; then
echo "[Error] macOS package script can be run on Darwin-type OS only."
exit 1
fi

echo "=> Preparing package build"
export QT_CELLAR_PREFIX="$(/usr/bin/find /usr/local/Cellar/qt -d 1 | sort -t '.' -k 1,1n -k 2,2n -k 3,3n | tail -n 1)"

GIT_HASH=$(git rev-parse --short HEAD)
GIT_BRANCH_OR_TAG=$(git name-rev --name-only HEAD | awk -F/ '{print $NF}')

PKG_VERSION="$GIT_HASH-$GIT_BRANCH_OR_TAG"

FILENAME_UNSIGNED="$PLUGIN_NAME-$PKG_VERSION-Unsigned.pkg"
FILENAME="$PLUGIN_NAME-$PKG_VERSION.pkg"

# echo "=> Modifying $PLUGIN_NAME.so"
# install_name_tool \
# -change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets \
# @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
# -change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui \
# @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui \
# -change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore \
# @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore \
# ./build/src/obs-plugin/obs-mac-virtualcam.so

# Check if replacement worked
echo "=> Dependencies for $PLUGIN_NAME"
otool -L ./build/src/obs-plugin/obs-mac-virtualcam.so

if [[ "$RELEASE_MODE" == "True" ]]; then
echo "=> Signing plugin binary: $PLUGIN_NAME.so"
codesign --sign "$CODE_SIGNING_IDENTITY" ./build/src/obs-plugin/obs-mac-virtualcam.so
codesign --sign "$CODE_SIGNING_IDENTITY" --force --deep ./build/src/dal-plugin/obs-mac-virtualcam.plugin
else
echo "=> Skipped plugin codesigning"
fi

# Fetch and install Packages app
# =!= NOTICE =!=
# Installs a LaunchDaemon under /Library/LaunchDaemons/fr.whitebox.packages.build.dispatcher.plist
# =!= NOTICE =!=
echo "=> Installing Packaging app (might require password due to 'sudo').."
curl -o './Packages.pkg' --retry-connrefused -s --retry-delay 1 'https://s3-us-west-2.amazonaws.com/obs-nightly/Packages.pkg'
sudo installer -pkg ./Packages.pkg -target /

echo "=> Actual package build"
packagesbuild ./installer/installer-macOS.generated.pkgproj

echo "=> Renaming $PLUGIN_NAME.pkg to $FILENAME"
mv ./release/$PLUGIN_NAME.pkg ./release/$FILENAME_UNSIGNED

if [[ "$RELEASE_MODE" == "True" ]]; then
echo "=> Signing installer: $FILENAME"
productsign \
--sign "$INSTALLER_SIGNING_IDENTITY" \
./release/$FILENAME_UNSIGNED \
./release/$FILENAME
rm ./release/$FILENAME_UNSIGNED

echo "=> Submitting installer $FILENAME for notarization"
zip -r ./release/$FILENAME.zip ./release/$FILENAME
UPLOAD_RESULT=$(xcrun altool \
--notarize-app \
--primary-bundle-id "$MACOS_BUNDLEID" \
--username "$AC_USERNAME" \
--password "$AC_PASSWORD" \
--asc-provider "$AC_PROVIDER_SHORTNAME" \
--file "./release/$FILENAME.zip")
rm ./release/$FILENAME.zip

REQUEST_UUID=$(echo $UPLOAD_RESULT | awk -F ' = ' '/RequestUUID/ {print $2}')
echo "Request UUID: $REQUEST_UUID"

echo "=> Wait for notarization result"
# Pieces of code borrowed from rednoah/notarized-app
while sleep 30 && date; do
CHECK_RESULT=$(xcrun altool \
--notarization-info "$REQUEST_UUID" \
--username "$AC_USERNAME" \
--password "$AC_PASSWORD" \
--asc-provider "$AC_PROVIDER_SHORTNAME")
echo $CHECK_RESULT

if ! grep -q "Status: in progress" <<< "$CHECK_RESULT"; then
echo "=> Staple ticket to installer: $FILENAME"
xcrun stapler staple ./release/$FILENAME
break
fi
done
else
echo "=> Skipped installer codesigning and notarization"
fi
Empty file added data/locale/en-US.ini
Empty file.

0 comments on commit 5db91b4

Please sign in to comment.