Skip to content

Commit

Permalink
CI: Update FFmpeg build workflow and action for native Windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav committed Jul 18, 2023
1 parent 926b94d commit 0e4e555
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 161 deletions.
147 changes: 105 additions & 42 deletions .github/actions/build-ffmpeg/action.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,141 @@
name: 'Build FFmpeg'
description: 'Builds FFmpeg for obs-deps with specified architecture, type, and build config'
name: Build FFmpeg
description: Builds FFmpeg for obs-deps with specified architecture, type, and build config
inputs:
target:
description: 'Build target for FFmpeg'
description: Build target for FFmpeg
required: true
type:
description: 'Build type (shared or static libraries)'
description: Build type (shared or static libraries)
required: false
default: 'static'
default: static
config:
description: 'Build configuration'
description: Build configuration
required: false
default: 'Release'
cacheRevision:
description: 'Cache revision number to force creation of new cache generation'
default: Release
workingDirectory:
description: Working directory for repository action
required: false
default: '01'
default: ${{ github.workspace }}
runs:
using: 'composite'
using: composite
steps:
- name: Environment Setup
id: ffmpeg-env-setup
id: env-setup
shell: bash
working-directory: ${{ inputs.workingDirectory }}
run: |
case "${{ runner.os }}" in
Linux)
if ! type zsh > /dev/null 2>&1; then
sudo apt update
sudo apt install zsh
fi
;;
case "${RUNNER_OS}" in
macOS)
if ! type sha256sum > /dev/null 2>&1; then
brew install coreutils
fi
ffmpeg_dep_hash=$(cat ${PWD}/deps.ffmpeg/*.zsh | sha256sum | cut -d " " -f 1)
;;
Windows)
ffmpeg_dep_hash=$(cat ${PWD}/deps.ffmpeg/*.ps1 | sha256sum | cut -d " " -f 1)
;;
esac
ffmpeg_dep_hash=$(cat ${{ github.workspace }}/deps.ffmpeg/*.zsh | sha256sum | cut -d " " -f 1)
echo "hash=${ffmpeg_dep_hash}" >> $GITHUB_OUTPUT
echo "hash=${ffmpeg_dep_hash:0:9}" >> $GITHUB_OUTPUT
- name: Restore FFmpeg Dependencies from Cache
id: ffmpeg-deps-cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/*_build_temp/*
!${{ github.workspace }}/*_build_temp/**/.git
!${{ github.workspace }}/*_build_temp/*.tar.gz
!${{ github.workspace }}/*_build_temp/*.tar.xz
!${{ github.workspace }}/*_build_temp/*.zip
!${{ github.workspace }}/*_build_temp/FFmpeg*
!${{ github.workspace }}/*_build_temp/x264-*-shared/
key: ${{ inputs.target }}-ffmpeg-deps-${{ inputs.type }}-${{ steps.ffmpeg-env-setup.outputs.hash }}-${{ inputs.cacheRevision }}
${{ inputs.workingDirectory }}/*_build_temp/*
!${{ inputs.workingDirectory }}/*_build_temp/**/.git
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.gz
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.xz
!${{ inputs.workingDirectory }}/*_build_temp/*.zip
!${{ inputs.workingDirectory }}/*_build_temp/FFmpeg*
!${{ inputs.workingDirectory }}/*_build_temp/x264-*-shared/
key: ${{ inputs.target }}-ffmpeg-deps-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}

- name: Build and Install FFmpeg Dependencies
if: ${{ steps.ffmpeg-deps-cache.outputs.cache-hit != 'true' }}
shell: zsh {0}
run: ./build-ffmpeg.zsh '*~ffmpeg' --target ${{ inputs.target }} --config ${{ inputs.config }} --${{ inputs.type }}
if: runner.os == 'macOS' && steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
shell: zsh --no-rcs --errexit --pipefail {0}
run: |
: Build and Install FFmpeg Dependencies
./build-ffmpeg.zsh '*~ffmpeg' --target ${{ inputs.target }} --config ${{ inputs.config }} --${{ inputs.type }}
- name: Build and Install FFmpeg Dependencies
if: runner.os == 'Windows' && steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
# Build and Install FFmpeg Dependencies
$BuildArgs = @{
PackageName = 'ffmpeg'
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
Shared = $(if ( '${{ inputs.type }}' -eq 'shared' ) { $true } else { $false })
Dependencies = (Get-ChildItem deps.ffmpeg -filter '*.ps1' | Where-Object { $_.Name -ne '99-ffmpeg.ps1' } | ForEach-Object { $_.Name -replace "[0-9]+-(.+).ps1",'$1' })
}
./Build-Dependencies.ps1 @BuildArgs
- name: Restore FFmpeg from Cache
id: ffmpeg-cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/*_build_temp/FFmpeg*/*
!${{ github.workspace }}/*_build_temp/FFmpeg*/.git
key: ${{ inputs.target }}-ffmpeg-${{ inputs.type }}-${{ steps.ffmpeg-env-setup.outputs.hash }}-${{ inputs.cacheRevision }}
key: ${{ inputs.target }}-ffmpeg-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}

- name: Build and Install FFmpeg
if: runner.os == 'macOS'
shell: zsh --no-rcs --errexit --pipefail {0}
run: |
: Build and Install FFmpeg
- name: Install FFmpeg
if: ${{ steps.ffmpeg-cache.outputs.cache-hit == 'true' }}
shell: zsh {0}
run: ./build-ffmpeg.zsh --skip-build --skip-unpack --target ${{ inputs.target }} --config ${{ inputs.config }} --${{ inputs.type }}
local -a build_args=(
--target ${{ inputs.target }}
--config ${{ inputs.config }}
--${{ inputs.type }}
)
if [[ '${{ steps.ffmpeg-cache.outputs.cache-hit }}' == 'true' ]] build_args+=(--skip-build --skip-unpack)
./build-ffmpeg.zsh ${build_args}
- name: Build and Install FFmpeg
if: ${{ steps.ffmpeg-cache.outputs.cache-hit != 'true' }}
shell: zsh {0}
run: ./build-ffmpeg.zsh --target ${{ inputs.target }} --config ${{ inputs.config }} --${{ inputs.type }}
if: runner.os == 'Windows'
shell: pwsh
run: |
# Build and Install FFmpeg
$BuildArgs = @{
Package = 'ffmpeg'
Target = '${{ inputs.target }}'
Config = '${{ inputs.config }}'
Shared = $(if ( '${{ inputs.type }}' -eq 'shared' ) { $true } else { $false })
SkipBuild = $(if ( '${{ steps.ffmpeg-cache.outputs.cache-hit }}' -eq 'true' ) { $true } else { $false })
SkipUnpack = $(if ( '${{ steps.ffmpeg-cache.outputs.cache-hit }}' -eq 'true' ) { $true } else { $false })
}
./Build-Dependencies.ps1 @BuildArgs
- name: Save FFmpeg to Cache
if: github.event_name == 'push'
uses: actions/cache/save@v3
with:
path: |
${{ github.workspace }}/*_build_temp/FFmpeg*/*
!${{ github.workspace }}/*_build_temp/FFmpeg*/.git
key: ${{ inputs.target }}-ffmpeg-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}

- name: Save FFmpeg Dependencies to Cache
if: github.event_name == 'push'
uses: actions/cache/save@v3
with:
path: |
${{ inputs.workingDirectory }}/*_build_temp/*
!${{ inputs.workingDirectory }}/*_build_temp/**/.git
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.gz
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.xz
!${{ inputs.workingDirectory }}/*_build_temp/*.zip
!${{ inputs.workingDirectory }}/*_build_temp/FFmpeg*
!${{ inputs.workingDirectory }}/*_build_temp/x264-*-shared/
key: ${{ inputs.target }}-ffmpeg-deps-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}
1 change: 1 addition & 0 deletions .github/actions/build-qt/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ runs:
# Build and Install Windows Qt
$Params = @{
Package = 'qt'
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
Shared = $true
Expand Down
Loading

0 comments on commit 0e4e555

Please sign in to comment.