From e9b7d473e992034e9eb39373ab2ec63b005ca59b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 1 Apr 2026 14:11:09 -0700 Subject: [PATCH 1/4] Replace template CI with Nix-based setup Delete the OBS plugin template CI infrastructure (~2800 lines of zsh/pwsh scripts, 6 composite actions, 3 complex workflows) and replace with: - Nix flake providing deterministic deps (clang-format, gersemi, cmake, ninja, pkg-config, ffmpeg, obs-studio on Linux) - Simple justfile recipes for check/fix/build (no more build-aux scripts) - Two minimal GitHub workflows: PR checks + push/release - Tag-triggered release automation with artifact uploads Also fixes: - FFmpeg not found in CI (now provided by Nix) - clang-format version pin breaking local dev (no longer pinned to 19.1.1) - xattr permission errors in macOS buildspec.cmake Co-Authored-By: Claude Opus 4.6 (1M context) --- .envrc | 1 + .github/actions/build-plugin/action.yaml | 113 ------- .github/actions/check-changes/action.yaml | 77 ----- .github/actions/package-plugin/action.yaml | 113 ------- .github/actions/run-clang-format/action.yaml | 60 ---- .github/actions/run-gersemi/action.yaml | 59 ---- .../setup-macos-codesigning/action.yaml | 159 ---------- .github/scripts/.Aptfile | 6 - .github/scripts/.Brewfile | 5 - .github/scripts/Build-Windows.ps1 | 86 ----- .github/scripts/Package-Windows.ps1 | 72 ----- .github/scripts/build-macos | 153 --------- .github/scripts/build-ubuntu | 232 -------------- .github/scripts/package-macos | 173 ---------- .github/scripts/package-ubuntu | 176 ----------- .../scripts/utils.pwsh/Ensure-Location.ps1 | 29 -- .../scripts/utils.pwsh/Invoke-External.ps1 | 40 --- .github/scripts/utils.pwsh/Logger.ps1 | 149 --------- .github/scripts/utils.zsh/check_macos | 11 - .github/scripts/utils.zsh/check_ubuntu | 61 ---- .github/scripts/utils.zsh/log_debug | 1 - .github/scripts/utils.zsh/log_error | 1 - .github/scripts/utils.zsh/log_group | 12 - .github/scripts/utils.zsh/log_info | 1 - .github/scripts/utils.zsh/log_output | 1 - .github/scripts/utils.zsh/log_status | 1 - .github/scripts/utils.zsh/log_warning | 1 - .github/scripts/utils.zsh/mkcd | 1 - .github/scripts/utils.zsh/set_loglevel | 17 - .github/scripts/utils.zsh/setup_ubuntu | 66 ---- .github/workflows/build-project.yaml | 297 ------------------ .github/workflows/check-format.yaml | 27 -- .github/workflows/dispatch.yaml | 18 -- .github/workflows/pr-pull.yaml | 54 +++- .github/workflows/push.yaml | 168 ++++------ build-aux/.functions/log_debug | 3 - build-aux/.functions/log_error | 3 - build-aux/.functions/log_group | 16 - build-aux/.functions/log_info | 7 - build-aux/.functions/log_output | 7 - build-aux/.functions/log_status | 7 - build-aux/.functions/log_warning | 7 - build-aux/.functions/set_loglevel | 17 - build-aux/.run-format.zsh | 272 ---------------- build-aux/run-clang-format | 1 - build-aux/run-gersemi | 1 - build-aux/run-swift-format | 1 - cmake/macos/buildspec.cmake | 1 - flake.lock | 61 ++++ flake.nix | 51 +++ justfile | 102 +++--- src/moq-output.cpp | 3 +- src/moq-output.h | 73 ++--- src/moq-service.cpp | 8 +- src/moq-service.h | 18 +- src/moq-source.cpp | 119 ++++--- 56 files changed, 372 insertions(+), 2847 deletions(-) create mode 100644 .envrc delete mode 100644 .github/actions/build-plugin/action.yaml delete mode 100644 .github/actions/check-changes/action.yaml delete mode 100644 .github/actions/package-plugin/action.yaml delete mode 100644 .github/actions/run-clang-format/action.yaml delete mode 100644 .github/actions/run-gersemi/action.yaml delete mode 100644 .github/actions/setup-macos-codesigning/action.yaml delete mode 100644 .github/scripts/.Aptfile delete mode 100644 .github/scripts/.Brewfile delete mode 100644 .github/scripts/Build-Windows.ps1 delete mode 100644 .github/scripts/Package-Windows.ps1 delete mode 100755 .github/scripts/build-macos delete mode 100755 .github/scripts/build-ubuntu delete mode 100755 .github/scripts/package-macos delete mode 100755 .github/scripts/package-ubuntu delete mode 100644 .github/scripts/utils.pwsh/Ensure-Location.ps1 delete mode 100644 .github/scripts/utils.pwsh/Invoke-External.ps1 delete mode 100644 .github/scripts/utils.pwsh/Logger.ps1 delete mode 100644 .github/scripts/utils.zsh/check_macos delete mode 100644 .github/scripts/utils.zsh/check_ubuntu delete mode 100644 .github/scripts/utils.zsh/log_debug delete mode 100644 .github/scripts/utils.zsh/log_error delete mode 100644 .github/scripts/utils.zsh/log_group delete mode 100644 .github/scripts/utils.zsh/log_info delete mode 100644 .github/scripts/utils.zsh/log_output delete mode 100644 .github/scripts/utils.zsh/log_status delete mode 100644 .github/scripts/utils.zsh/log_warning delete mode 100644 .github/scripts/utils.zsh/mkcd delete mode 100644 .github/scripts/utils.zsh/set_loglevel delete mode 100644 .github/scripts/utils.zsh/setup_ubuntu delete mode 100644 .github/workflows/build-project.yaml delete mode 100644 .github/workflows/check-format.yaml delete mode 100644 .github/workflows/dispatch.yaml delete mode 100644 build-aux/.functions/log_debug delete mode 100644 build-aux/.functions/log_error delete mode 100644 build-aux/.functions/log_group delete mode 100644 build-aux/.functions/log_info delete mode 100644 build-aux/.functions/log_output delete mode 100644 build-aux/.functions/log_status delete mode 100644 build-aux/.functions/log_warning delete mode 100644 build-aux/.functions/set_loglevel delete mode 100755 build-aux/.run-format.zsh delete mode 120000 build-aux/run-clang-format delete mode 120000 build-aux/run-gersemi delete mode 120000 build-aux/run-swift-format create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/actions/build-plugin/action.yaml b/.github/actions/build-plugin/action.yaml deleted file mode 100644 index e5839ea..0000000 --- a/.github/actions/build-plugin/action.yaml +++ /dev/null @@ -1,113 +0,0 @@ -name: Set up and build plugin -description: Builds the plugin for specified architecture and build config -inputs: - target: - description: Target architecture for dependencies - required: true - config: - description: Build configuration - required: false - default: RelWithDebInfo - codesign: - description: Enable codesigning (macOS only) - required: false - default: 'false' - codesignIdent: - description: Developer ID for application codesigning (macOS only) - required: false - default: '-' - codesignTeam: - description: Team ID for application codesigning (macOS only) - required: false - default: '' - workingDirectory: - description: Working directory for packaging - required: false - default: ${{ github.workspace }} -runs: - using: composite - steps: - - name: Run macOS Build - if: runner.os == 'macOS' - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ inputs.workingDirectory }} - env: - CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache - CODESIGN_IDENT: ${{ inputs.codesignIdent }} - CODESIGN_TEAM: ${{ inputs.codesignTeam }} - run: | - : Run macOS Build - - local -a build_args=(--config ${{ inputs.config }}) - if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) - - if [[ '${{ inputs.codesign }}' == 'true' ]] build_args+=(--codesign) - - .github/scripts/build-macos ${build_args} - - - name: Install Dependencies 🛍️ - if: runner.os == 'Linux' - shell: bash - run: | - : Install Dependencies 🛍️ - echo ::group::Install Dependencies - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - brew install --quiet zsh - echo ::endgroup:: - - - name: Run Ubuntu Build - if: runner.os == 'Linux' - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ inputs.workingDirectory }} - env: - CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache - run: | - : Run Ubuntu Build - - local -a build_args=( - --target ubuntu-${{ inputs.target }} - --config ${{ inputs.config }} - ) - if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) - - .github/scripts/build-ubuntu ${build_args} - - - name: Run Windows Build - if: runner.os == 'Windows' - shell: pwsh - run: | - # Run Windows Build - if ( $Env:RUNNER_DEBUG -ne $null ) { - Set-PSDebug -Trace 1 - } - - $BuildArgs = @{ - Target = '${{ inputs.target }}' - Configuration = '${{ inputs.config }}' - } - - .github/scripts/Build-Windows.ps1 @BuildArgs - - - name: Create Summary 📊 - if: contains(fromJSON('["Linux", "macOS"]'),runner.os) - shell: zsh --no-rcs --errexit --pipefail {0} - env: - CCACHE_DIR: ${{ inputs.workingDirectory }}/.ccache - run: | - : Create Summary 📊 - - local -a ccache_data - if (( ${+RUNNER_DEBUG} )) { - setopt XTRACE - ccache_data=("${(fA)$(ccache -s -vv)}") - } else { - ccache_data=("${(fA)$(ccache -s)}") - } - - print '### ${{ runner.os }} Ccache Stats (${{ inputs.target }})' >> $GITHUB_STEP_SUMMARY - print '```' >> $GITHUB_STEP_SUMMARY - for line (${ccache_data}) { - print ${line} >> $GITHUB_STEP_SUMMARY - } - print '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/actions/check-changes/action.yaml b/.github/actions/check-changes/action.yaml deleted file mode 100644 index 50d1679..0000000 --- a/.github/actions/check-changes/action.yaml +++ /dev/null @@ -1,77 +0,0 @@ -name: Check For Changed Files -description: Checks for changed files compared to specific git reference and glob expression -inputs: - baseRef: - description: Git reference to check against - required: false - ref: - description: Git reference to check with - required: false - default: HEAD - checkGlob: - description: Glob expression to limit check to specific files - required: false - useFallback: - description: Use fallback compare against prior commit - required: false - default: 'true' - diffFilter: - description: git diff-filter string to use - required: false - default: '' -outputs: - hasChangedFiles: - value: ${{ steps.checks.outputs.hasChangedFiles }} - description: True if specified files were changed in comparison to specified git reference - changedFiles: - value: ${{ steps.checks.outputs.changedFiles }} - description: List of changed files -runs: - using: composite - steps: - - name: Check For Changed Files ✅ - shell: bash - id: checks - env: - GIT_BASE_REF: ${{ inputs.baseRef }} - GIT_REF: ${{ inputs.ref }} - GITHUB_EVENT_FORCED: ${{ github.event.forced }} - GITHUB_REF_BEFORE: ${{ github.event.before }} - USE_FALLBACK: ${{ inputs.useFallback }} - DIFF_FILTER: ${{ inputs.diffFilter }} - run: | - : Check for Changed Files ✅ - if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi - shopt -s extglob - shopt -s dotglob - - if [[ "${GIT_BASE_REF}" ]]; then - if ! git cat-file -e "${GIT_BASE_REF}" &> /dev/null; then - echo "::warning::Provided base reference ${GIT_BASE_REF} is invalid" - if [[ "${USE_FALLBACK}" == 'true' ]]; then - GIT_BASE_REF='HEAD~1' - fi - fi - else - if ! git cat-file -e ${GITHUB_REF_BEFORE} &> /dev/null; then - GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904' - fi - - GIT_BASE_REF='HEAD~1' - case "${GITHUB_EVENT_NAME}" in - pull_request) GIT_BASE_REF="origin/${GITHUB_BASE_REF}" ;; - push) if [[ "${GITHUB_EVENT_FORCED}" != 'true' ]]; then GIT_BASE_REF="${GITHUB_REF_BEFORE}"; fi ;; - *) ;; - esac - fi - - changes=($(git diff --name-only --diff-filter="${DIFF_FILTER}" ${GIT_BASE_REF} ${GIT_REF} -- ${{ inputs.checkGlob }})) - - if (( ${#changes[@]} )); then - file_string="${changes[*]}" - echo "hasChangedFiles=true" >> $GITHUB_OUTPUT - echo "changedFiles=[\"${file_string// /\",\"}\"]" >> $GITHUB_OUTPUT - else - echo "hasChangedFiles=false" >> $GITHUB_OUTPUT - echo "changedFiles=[]" >> GITHUB_OUTPUT - fi diff --git a/.github/actions/package-plugin/action.yaml b/.github/actions/package-plugin/action.yaml deleted file mode 100644 index 11fdccf..0000000 --- a/.github/actions/package-plugin/action.yaml +++ /dev/null @@ -1,113 +0,0 @@ -name: Package plugin -description: Packages the plugin for specified architecture and build config. -inputs: - target: - description: Build target for dependencies - required: true - config: - description: Build configuration - required: false - default: RelWithDebInfo - codesign: - description: Enable codesigning (macOS only) - required: false - default: 'false' - notarize: - description: Enable notarization (macOS only) - required: false - default: 'false' - codesignIdent: - description: Developer ID for application codesigning (macOS only) - required: false - default: '-' - installerIdent: - description: Developer ID for installer package codesigning (macOS only) - required: false - default: '' - codesignTeam: - description: Developer team for codesigning (macOS only) - required: false - default: '' - codesignUser: - description: Apple ID username for notarization (macOS only) - required: false - default: '' - codesignPass: - description: Apple ID password for notarization (macOS only) - required: false - default: '' - package: - description: Create Windows or macOS installation package - required: false - default: 'false' - workingDirectory: - description: Working directory for packaging - required: false - default: ${{ github.workspace }} -runs: - using: composite - steps: - - name: Run macOS Packaging - if: runner.os == 'macOS' - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ inputs.workingDirectory }} - env: - CODESIGN_IDENT: ${{ inputs.codesignIdent }} - CODESIGN_IDENT_INSTALLER: ${{ inputs.installerIdent }} - CODESIGN_TEAM: ${{ inputs.codesignTeam }} - CODESIGN_IDENT_USER: ${{ inputs.codesignUser }} - CODESIGN_IDENT_PASS: ${{ inputs.codesignPass }} - run: | - : Run macOS Packaging - - local -a package_args=(--config ${{ inputs.config }}) - if (( ${+RUNNER_DEBUG} )) package_args+=(--debug) - - if [[ '${{ inputs.codesign }}' == 'true' ]] package_args+=(--codesign) - if [[ '${{ inputs.notarize }}' == 'true' ]] package_args+=(--notarize) - if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) - - .github/scripts/package-macos ${package_args} - - - name: Install Dependencies 🛍️ - if: runner.os == 'Linux' - shell: bash - run: | - : Install Dependencies 🛍️ - echo ::group::Install Dependencies - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - brew install --quiet zsh - echo ::endgroup:: - - - name: Run Ubuntu Packaging - if: runner.os == 'Linux' - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ inputs.workingDirectory }} - run: | - : Run Ubuntu Packaging - package_args=( - --target ubuntu-${{ inputs.target }} - --config ${{ inputs.config }} - ) - if (( ${+RUNNER_DEBUG} )) build_args+=(--debug) - - if [[ '${{ inputs.package }}' == 'true' ]] package_args+=(--package) - - .github/scripts/package-ubuntu ${package_args} - - - name: Run Windows Packaging - if: runner.os == 'Windows' - shell: pwsh - run: | - # Run Windows Packaging - if ( $Env:RUNNER_DEBUG -ne $null ) { - Set-PSDebug -Trace 1 - } - - $PackageArgs = @{ - Target = '${{ inputs.target }}' - Configuration = '${{ inputs.config }}' - } - - .github/scripts/Package-Windows.ps1 @PackageArgs diff --git a/.github/actions/run-clang-format/action.yaml b/.github/actions/run-clang-format/action.yaml deleted file mode 100644 index 3f3f8e5..0000000 --- a/.github/actions/run-clang-format/action.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: Run clang-format -description: Runs clang-format and checks for any changes introduced by it -inputs: - failCondition: - description: Controls whether failed checks also fail the workflow run - required: false - default: never - workingDirectory: - description: Working directory for checks - required: false - default: ${{ github.workspace }} -runs: - using: composite - steps: - - name: Check Runner Operating System 🏃‍♂️ - if: runner.os == 'Windows' - shell: bash - run: | - : Check Runner Operating System 🏃‍♂️ - echo "::notice::run-clang-format action requires a macOS-based or Linux-based runner." - exit 2 - - - name: Check for Changed Files ✅ - uses: ./.github/actions/check-changes - id: checks - with: - checkGlob: "'*.c' '*.h' '*.cpp' '*.hpp' '*.m' '*.mm'" - diffFilter: 'ACM' - - - name: Install Dependencies 🛍️ - if: runner.os == 'Linux' && fromJSON(steps.checks.outputs.hasChangedFiles) - shell: bash - run: | - : Install Dependencies 🛍️ - echo ::group::Install Dependencies - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - echo "/home/linuxbrew/.linuxbrew/opt/clang-format@19/bin" >> $GITHUB_PATH - brew install --quiet zsh - echo ::endgroup:: - - - name: Run clang-format 🐉 - if: fromJSON(steps.checks.outputs.hasChangedFiles) - id: result - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ inputs.workingDirectory }} - env: - CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }} - run: | - : Run clang-format 🐉 - if (( ${+RUNNER_DEBUG} )) setopt XTRACE - - print ::group::Install clang-format-19 - brew install --quiet obsproject/tools/clang-format@19 - print ::endgroup:: - - print ::group::Run clang-format-19 - local -a changes=(${(s:,:)CHANGED_FILES//[\[\]\'\"]/}) - ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check ${changes} - print ::endgroup:: diff --git a/.github/actions/run-gersemi/action.yaml b/.github/actions/run-gersemi/action.yaml deleted file mode 100644 index 5a6818f..0000000 --- a/.github/actions/run-gersemi/action.yaml +++ /dev/null @@ -1,59 +0,0 @@ -name: Run gersemi -description: Runs gersemi and checks for any changes introduced by it -inputs: - failCondition: - description: Controls whether failed checks also fail the workflow run - required: false - default: never - workingDirectory: - description: Working directory for checks - required: false - default: ${{ github.workspace }} -runs: - using: composite - steps: - - name: Check Runner Operating System 🏃‍♂️ - if: runner.os == 'Windows' - shell: bash - run: | - : Check Runner Operating System 🏃‍♂️ - echo "::notice::run-gersemi action requires a macOS-based or Linux-based runner." - exit 2 - - - name: Check for Changed Files ✅ - uses: ./.github/actions/check-changes - id: checks - with: - checkGlob: "'*.cmake' '*CMakeLists.txt'" - diffFilter: 'ACM' - - - name: Install Dependencies 🛍️ - if: runner.os == 'Linux' && fromJSON(steps.checks.outputs.hasChangedFiles) - shell: bash - run: | - : Install Dependencies 🛍️ - echo ::group::Install Dependencies - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - brew install --quiet zsh - echo ::endgroup:: - - - name: Run gersemi 🎛️ - if: fromJSON(steps.checks.outputs.hasChangedFiles) - id: result - shell: zsh --no-rcs --errexit --pipefail {0} - working-directory: ${{ github.workspace }} - env: - CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }} - run: | - : Run gersemi 🎛️ - if (( ${+RUNNER_DEBUG} )) setopt XTRACE - - print ::group::Install gersemi - brew install --quiet obsproject/tools/gersemi - print ::endgroup:: - - print ::group::Run gersemi - local -a changes=(${(s:,:)CHANGED_FILES//[\[\]\'\"]/}) - ./build-aux/run-gersemi --fail-${{ inputs.failCondition }} --check ${changes} - print ::endgroup:: diff --git a/.github/actions/setup-macos-codesigning/action.yaml b/.github/actions/setup-macos-codesigning/action.yaml deleted file mode 100644 index c7bfcb0..0000000 --- a/.github/actions/setup-macos-codesigning/action.yaml +++ /dev/null @@ -1,159 +0,0 @@ -name: Set up macOS codesigning -description: Sets up code signing certificates, provisioning profiles, and notarization information -inputs: - codesignIdentity: - description: Codesigning identity - required: true - installerIdentity: - description: Codesigning identity for package installer - required: false - codesignCertificate: - description: PKCS12 certificate in base64 format - required: true - certificatePassword: - description: Password required to install PKCS12 certificate - required: true - keychainPassword: - description: Password to use for temporary keychain - required: false - notarizationUser: - description: Apple ID to use for notarization - required: false - notarizationPassword: - description: Application password for notarization - provisioningProfile: - description: Provisioning profile in base64 format - required: false -outputs: - haveCodesignIdent: - description: True if necessary codesigning credentials were found - value: ${{ steps.codesign.outputs.haveCodesignIdent }} - haveProvisioningProfile: - description: True if necessary provisioning profile credentials were found - value: ${{ steps.provisioning.outputs.haveProvisioningProfile || steps.codesign.outputs.haveProvisioningProfile }} - provisioningProfileUUID: - description: UUID of imported provisioning profile - value: ${{ steps.provisioning.outputs.provisioningProfileUUID }} - haveNotarizationUser: - description: True if necessary notarization credentials were found - value: ${{ steps.notarization.outputs.haveNotarizationUser || steps.codesign.outputs.haveNotarizationUser }} - codesignIdent: - description: Codesigning identity - value: ${{ steps.codesign.outputs.codesignIdent }} - installerIdent: - description: Codesigning identity for package installer - value: ${{ steps.codesign.outputs.installerIdent }} - codesignTeam: - description: Codesigning team - value: ${{ steps.codesign.outputs.codesignTeam }} -runs: - using: composite - steps: - - name: Check Runner Operating System 🏃‍♂️ - if: runner.os != 'macOS' - shell: bash - run: | - : Check Runner Operating System 🏃‍♂️ - echo "setup-macos-codesigning action requires a macOS-based runner." - exit 2 - - - name: macOS Codesigning ✍️ - shell: zsh --no-rcs --errexit --pipefail {0} - id: codesign - env: - MACOS_SIGNING_IDENTITY: ${{ inputs.codesignIdentity }} - MACOS_SIGNING_IDENTITY_INSTALLER: ${{ inputs.installerIdentity}} - MACOS_SIGNING_CERT: ${{ inputs.codesignCertificate }} - MACOS_SIGNING_CERT_PASSWORD: ${{ inputs.certificatePassword }} - MACOS_KEYCHAIN_PASSWORD: ${{ inputs.keychainPassword }} - run: | - : macOS Code Signing ✍️ - if (( ${+RUNNER_DEBUG} )) setopt XTRACE - - if [[ ${MACOS_SIGNING_IDENTITY} && ${MACOS_SIGNING_IDENTITY_INSTALLER} && ${MACOS_SIGNING_CERT} ]] { - print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT - - local -r certificate_path="${RUNNER_TEMP}/build_certificate.p12" - local -r keychain_path="${RUNNER_TEMP}/app-signing.keychain-db" - - print -n "${MACOS_SIGNING_CERT}" | base64 --decode --output=${certificate_path} - - : "${MACOS_KEYCHAIN_PASSWORD:="$(print ${RANDOM} | shasum | head -c 32)"}" - - print '::group::Keychain setup' - security create-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} - security set-keychain-settings -lut 21600 ${keychain_path} - security unlock-keychain -p "${MACOS_KEYCHAIN_PASSWORD}" ${keychain_path} - - security import "${certificate_path}" -P "${MACOS_SIGNING_CERT_PASSWORD}" -A \ - -t cert -f pkcs12 -k ${keychain_path} \ - -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun - - security set-key-partition-list -S 'apple-tool:,apple:' -k "${MACOS_KEYCHAIN_PASSWORD}" \ - ${keychain_path} &> /dev/null - - security list-keychain -d user -s ${keychain_path} 'login-keychain' - print '::endgroup::' - - local -r team_id="${${MACOS_SIGNING_IDENTITY##* }//(\(|\))/}" - - print "codesignIdent=${MACOS_SIGNING_IDENTITY}" >> $GITHUB_OUTPUT - print "installerIdent=${MACOS_SIGNING_IDENTITY_INSTALLER}" >> $GITHUB_OUTPUT - print "MACOS_KEYCHAIN_PASSWORD=${MACOS_KEYCHAIN_PASSWORD}" >> $GITHUB_ENV - print "codesignTeam=${team_id}" >> $GITHUB_OUTPUT - } else { - print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT - print 'haveProvisioningProfile=false' >> $GITHUB_OUTPUT - print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT - } - - - name: Provisioning Profile 👤 - shell: zsh --no-rcs --errexit --pipefail {0} - id: provisioning - if: ${{ fromJSON(steps.codesign.outputs.haveCodesignIdent) }} - env: - MACOS_SIGNING_PROVISIONING_PROFILE: ${{ inputs.provisioningProfile }} - run: | - : Provisioning Profile 👤 - if (( ${+RUNNER_DEBUG} )) setopt XTRACE - - if [[ "${MACOS_SIGNING_PROVISIONING_PROFILE}" ]] { - print 'haveProvisioningProfile=true' >> $GITHUB_OUTPUT - - local -r profile_path="${RUNNER_TEMP}/build_profile.provisionprofile" - print -n "${MACOS_SIGNING_PROVISIONING_PROFILE}" \ - | base64 --decode --output="${profile_path}" - - print '::group::Provisioning Profile Setup' - mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles - security cms -D -i ${profile_path} -o ${RUNNER_TEMP}/build_profile.plist - local -r uuid="$(plutil -extract UUID raw ${RUNNER_TEMP}/build_profile.plist)" - local -r team_id="$(plutil -extract TeamIdentifier.0 raw -expect string ${RUNNER_TEMP}/build_profile.plist)" - - if [[ ${team_id} != '${{ steps.codesign.outputs.codesignTeam }}' ]] { - print '::notice::Code Signing team in provisioning profile does not match certificate.' - } - - cp ${profile_path} ~/Library/MobileDevice/Provisioning\ Profiles/${uuid}.provisionprofile - print "provisioningProfileUUID=${uuid}" >> $GITHUB_OUTPUT - print '::endgroup::' - } else { - print 'haveProvisioningProfile=false' >> $GITHUB_OUTPUT - } - - - name: Notarization 🧑‍💼 - id: notarization - if: fromJSON(steps.codesign.outputs.haveCodesignIdent) - shell: zsh --no-rcs --errexit --pipefail {0} - env: - MACOS_NOTARIZATION_USERNAME: ${{ inputs.notarizationUser }} - MACOS_NOTARIZATION_PASSWORD: ${{ inputs.notarizationPassword }} - run: | - : Notarization 🧑‍💼 - if (( ${+RUNNER_DEBUG} )) setopt XTRACE - - if [[ ${MACOS_NOTARIZATION_USERNAME} && ${MACOS_NOTARIZATION_PASSWORD} ]] { - print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT - } else { - print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT - } diff --git a/.github/scripts/.Aptfile b/.github/scripts/.Aptfile deleted file mode 100644 index 09efc11..0000000 --- a/.github/scripts/.Aptfile +++ /dev/null @@ -1,6 +0,0 @@ -package 'cmake' -package 'ccache' -package 'git' -package 'jq' -package 'ninja-build', bin: 'ninja' -package 'pkg-config' diff --git a/.github/scripts/.Brewfile b/.github/scripts/.Brewfile deleted file mode 100644 index 4464254..0000000 --- a/.github/scripts/.Brewfile +++ /dev/null @@ -1,5 +0,0 @@ -brew "ccache" -brew "coreutils" -brew "cmake" -brew "jq" -brew "xcbeautify" diff --git a/.github/scripts/Build-Windows.ps1 b/.github/scripts/Build-Windows.ps1 deleted file mode 100644 index d56e61d..0000000 --- a/.github/scripts/Build-Windows.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -[CmdletBinding()] -param( - [ValidateSet('x64')] - [string] $Target = 'x64', - [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] - [string] $Configuration = 'RelWithDebInfo' -) - -$ErrorActionPreference = 'Stop' - -if ( $DebugPreference -eq 'Continue' ) { - $VerbosePreference = 'Continue' - $InformationPreference = 'Continue' -} - -if ( $env:CI -eq $null ) { - throw "Build-Windows.ps1 requires CI environment" -} - -if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) { - throw "A 64-bit system is required to build the project." -} - -if ( $PSVersionTable.PSVersion -lt '7.2.0' ) { - Write-Warning 'The obs-studio PowerShell build script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6' - exit 2 -} - -function Build { - trap { - Pop-Location -Stack BuildTemp -ErrorAction 'SilentlyContinue' - Write-Error $_ - Log-Group - exit 2 - } - - $ScriptHome = $PSScriptRoot - $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.." - - $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse - - foreach($Utility in $UtilityFunctions) { - Write-Debug "Loading $($Utility.FullName)" - . $Utility.FullName - } - - Push-Location -Stack BuildTemp - Ensure-Location $ProjectRoot - - $CmakeArgs = @('--preset', "windows-ci-${Target}") - $CmakeBuildArgs = @('--build') - $CmakeInstallArgs = @() - - if ( $DebugPreference -eq 'Continue' ) { - $CmakeArgs += ('--debug-output') - $CmakeBuildArgs += ('--verbose') - $CmakeInstallArgs += ('--verbose') - } - - $CmakeBuildArgs += @( - '--preset', "windows-${Target}" - '--config', $Configuration - '--parallel' - '--', '/consoleLoggerParameters:Summary', '/noLogo' - ) - - $CmakeInstallArgs += @( - '--install', "build_${Target}" - '--prefix', "${ProjectRoot}/release/${Configuration}" - '--config', $Configuration - ) - - Log-Group "Configuring ${ProductName}..." - Invoke-External cmake @CmakeArgs - - Log-Group "Building ${ProductName}..." - Invoke-External cmake @CmakeBuildArgs - - Log-Group "Installing ${ProductName}..." - Invoke-External cmake @CmakeInstallArgs - - Pop-Location -Stack BuildTemp - Log-Group -} - -Build diff --git a/.github/scripts/Package-Windows.ps1 b/.github/scripts/Package-Windows.ps1 deleted file mode 100644 index 0425807..0000000 --- a/.github/scripts/Package-Windows.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -[CmdletBinding()] -param( - [ValidateSet('x64')] - [string] $Target = 'x64', - [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] - [string] $Configuration = 'RelWithDebInfo' -) - -$ErrorActionPreference = 'Stop' - -if ( $DebugPreference -eq 'Continue' ) { - $VerbosePreference = 'Continue' - $InformationPreference = 'Continue' -} - -if ( $env:CI -eq $null ) { - throw "Package-Windows.ps1 requires CI environment" -} - -if ( ! ( [System.Environment]::Is64BitOperatingSystem ) ) { - throw "Packaging script requires a 64-bit system to build and run." -} - -if ( $PSVersionTable.PSVersion -lt '7.2.0' ) { - Write-Warning 'The packaging script requires PowerShell Core 7. Install or upgrade your PowerShell version: https://aka.ms/pscore6' - exit 2 -} - -function Package { - trap { - Write-Error $_ - exit 2 - } - - $ScriptHome = $PSScriptRoot - $ProjectRoot = Resolve-Path -Path "$PSScriptRoot/../.." - $BuildSpecFile = "${ProjectRoot}/buildspec.json" - - $UtilityFunctions = Get-ChildItem -Path $PSScriptRoot/utils.pwsh/*.ps1 -Recurse - - foreach( $Utility in $UtilityFunctions ) { - Write-Debug "Loading $($Utility.FullName)" - . $Utility.FullName - } - - $BuildSpec = Get-Content -Path ${BuildSpecFile} -Raw | ConvertFrom-Json - $ProductName = $BuildSpec.name - $ProductVersion = $BuildSpec.version - - $OutputName = "${ProductName}-${ProductVersion}-windows-${Target}" - - $RemoveArgs = @{ - ErrorAction = 'SilentlyContinue' - Path = @( - "${ProjectRoot}/release/${ProductName}-*-windows-*.zip" - ) - } - - Remove-Item @RemoveArgs - - Log-Group "Archiving ${ProductName}..." - $CompressArgs = @{ - Path = (Get-ChildItem -Path "${ProjectRoot}/release/${Configuration}" -Exclude "${OutputName}*.*") - CompressionLevel = 'Optimal' - DestinationPath = "${ProjectRoot}/release/${OutputName}.zip" - Verbose = ($Env:CI -ne $null) - } - Compress-Archive -Force @CompressArgs - Log-Group -} - -Package diff --git a/.github/scripts/build-macos b/.github/scripts/build-macos deleted file mode 100755 index fece23b..0000000 --- a/.github/scripts/build-macos +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env zsh - -builtin emulate -L zsh -setopt EXTENDED_GLOB -setopt PUSHD_SILENT -setopt ERR_EXIT -setopt ERR_RETURN -setopt NO_UNSET -setopt PIPE_FAIL -setopt NO_AUTO_PUSHD -setopt NO_PUSHD_IGNORE_DUPS -setopt FUNCTION_ARGZERO - -## Enable for script debugging -# setopt WARN_CREATE_GLOBAL -# setopt WARN_NESTED_VAR -# setopt XTRACE - -if (( ! ${+CI} )) { - print -u2 -PR "%F{1} ✖︎ ${ZSH_ARGZERO:t:r} requires CI environment.%f" - exit 1 -} - -autoload -Uz is-at-least && if ! is-at-least 5.9; then - print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." - exit 1 -fi - -TRAPZERR() { - print -u2 -PR "::error::%F{1} ✖︎ script execution error%f" - print -PR -e " - Callstack: - ${(j:\n :)funcfiletrace} - " - - exit 2 -} - -build() { - if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} - local host_os='macos' - local project_root=${SCRIPT_HOME:A:h:h} - local buildspec_file=${project_root}/buildspec.json - - fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) - autoload -Uz log_group log_info log_error log_output check_macos setup_ccache - - if [[ ! -r ${buildspec_file} ]] { - log_error \ - 'No buildspec.json found. Please create a build specification for your project.' - return 2 - } - - local -i debug=0 - - local config='RelWithDebInfo' - local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) - local -i codesign=0 - - local -a args - while (( # )) { - case ${1} { - -c|--config) - if (( # == 1 )) || [[ ${2:0:1} == '-' ]] { - log_error "Missing value for option %B${1}%b" - log_output ${_usage} - exit 2 - } - ;; - } - case ${1} { - --) shift; args+=($@); break ;; - -c|--config) - if (( ! ${_valid_configs[(Ie)${2}]} )) { - log_error "Invalid value %B${2}%b for option %B${1}%b" - exit 2 - } - config=${2} - shift 2 - ;; - -s|--codesign) codesign=1; shift ;; - --debug) debug=1; shift ;; - *) log_error "Unknown option: %B${1}%b"; exit 2 ;; - } - } - - set -- ${(@)args} - - check_macos - - local product_name - local product_version - read -r product_name product_version <<< \ - "$(jq -r '. | {name, version} | join(" ")' ${buildspec_file})" - - pushd ${project_root} - - local -a cmake_args=() - local -a cmake_build_args=(--build) - local -a cmake_install_args=(--install) - - if (( debug )) cmake_args+=(--debug-output) - - cmake_args+=(--preset 'macos-ci') - - typeset -gx NSUnbufferedIO=YES - - typeset -gx CODESIGN_IDENT="${CODESIGN_IDENT:--}" - if (( codesign )) && [[ -z ${CODESIGN_TEAM} ]] { - typeset -gx CODESIGN_TEAM="$(print "${CODESIGN_IDENT}" | /usr/bin/sed -En 's/.+\((.+)\)/\1/p')" - } - - log_group "Configuring ${product_name}..." - cmake -S ${project_root} ${cmake_args} - - log_group "Building ${product_name}..." - run_xcodebuild() { - if (( debug )) { - xcodebuild ${@} - } else { - if [[ ${GITHUB_EVENT_NAME} == push ]] { - xcodebuild ${@} 2>&1 | xcbeautify --renderer terminal - } else { - xcodebuild ${@} 2>&1 | xcbeautify --renderer github-actions - } - } - } - - local -a build_args=( - ONLY_ACTIVE_ARCH=NO - -arch arm64 - -arch x86_64 - -project ${product_name}.xcodeproj - -target ${product_name} - -destination "generic/platform=macOS,name=Any Mac" - -configuration ${config} - -parallelizeTargets - -hideShellScriptEnvironment - build - ) - - pushd build_macos - run_xcodebuild ${build_args} - popd - - log_group "Installing ${product_name}..." - cmake --install build_macos --config ${config} --prefix "${project_root}/release/${config}" - - popd - log_group -} - -build ${@} diff --git a/.github/scripts/build-ubuntu b/.github/scripts/build-ubuntu deleted file mode 100755 index 895148d..0000000 --- a/.github/scripts/build-ubuntu +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/env zsh - -builtin emulate -L zsh -setopt EXTENDED_GLOB -setopt PUSHD_SILENT -setopt ERR_EXIT -setopt ERR_RETURN -setopt NO_UNSET -setopt PIPE_FAIL -setopt NO_AUTO_PUSHD -setopt NO_PUSHD_IGNORE_DUPS -setopt FUNCTION_ARGZERO - -## Enable for script debugging -# setopt WARN_CREATE_GLOBAL -# setopt WARN_NESTED_VAR -# setopt XTRACE - -autoload -Uz is-at-least && if ! is-at-least 5.2; then - print -u2 -PR "${CI:+::error::}%F{1}${funcstack[1]##*/}:%f Running on Zsh version %B${ZSH_VERSION}%b, but Zsh %B5.2%b is the minimum supported version. Upgrade Zsh to fix this issue." - exit 1 -fi - -TRAPZERR() { - if (( ${_loglevel:-3} > 2 )) { - print -u2 -PR "${CI:+::error::}%F{1} ✖︎ script execution error%f" - print -PR -e " - Callstack: - ${(j:\n :)funcfiletrace} - " - } - - exit 2 -} - -build() { - if (( ! ${+SCRIPT_HOME} )) typeset -g SCRIPT_HOME=${ZSH_ARGZERO:A:h} - local host_os='ubuntu' - local project_root=${SCRIPT_HOME:A:h:h} - local buildspec_file=${project_root}/buildspec.json - - fpath=("${SCRIPT_HOME}/utils.zsh" ${fpath}) - autoload -Uz log_group log_info log_error log_output set_loglevel check_ubuntu setup_ccache - - if [[ ! -r ${buildspec_file} ]] { - log_error \ - 'No buildspec.json found. Please create a build specification for your project.' - return 2 - } - - local -i debug=0 - typeset -g -a skips=() - local -i verbosity=1 - local -r _version='2.0.0' - local -r -a _valid_targets=( - ubuntu-x86_64 - ) - local target - local config='RelWithDebInfo' - local -r -a _valid_configs=(Debug RelWithDebInfo Release MinSizeRel) - local -i codesign=0 - - local -r -a _valid_generators=(Ninja 'Unix Makefiles') - local generator='Ninja' - local -r _usage_host=" -%F{yellow} Additional options for Linux builds%f - ----------------------------------------------------------------------------- - %B--generator%b Specify build system to generate - Available generators: - - Ninja - - Unix Makefiles" - - local -i print_config=0 - local -r _usage=" -Usage: %B${functrace[1]%:*}%b