Build FFmpeg #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build.yml: Build FFmpeg binaries. | |
# | |
name: 'Build FFmpeg' | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: 'Build FFmpeg' | |
runs-on: ${{ matrix.os }} | |
continue-on-error: true | |
strategy: | |
matrix: | |
name: [ | |
#alpine-aarch64, | |
alpine-arm32v7, | |
alpine-x86_64, | |
# darwin-arm64, | |
darwin-x86_64, | |
#windows-x86_64 | |
] | |
include: | |
# Build for arm v7 32-bit Linux environments. | |
- name: alpine-arm32v7 | |
os: ubuntu-latest | |
BASE_IMAGE: arm32v7/alpine:latest | |
DOCKERFILE: linux | |
EMULATE_ARCH: arm | |
TARGET_ARCH: arm32v7 | |
TARGET_OS: alpine | |
# Build for Intel 64-bit Linux environments. | |
- name: alpine-x86_64 | |
os: ubuntu-latest | |
BASE_IMAGE: library/alpine:latest | |
DOCKERFILE: linux | |
# This is intentional. | |
EMULATE_ARCH: aarch64 | |
TARGET_ARCH: x86_64 | |
TARGET_OS: alpine | |
# Build for Intel macOS environments. | |
- name: darwin-x86_64 | |
os: macos-13 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Caching workspace.' | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: build | |
key: ${{ matrix.name }}-cache | |
# Docker image build. | |
- name: 'Docker: creating the build image.' | |
if: runner.os == 'Linux' | |
run: | | |
# Configure QEMU to register handlers for our target architectures. | |
docker run --rm --privileged multiarch/qemu-user-static:register --reset | |
# Build the image that will become our build environment. | |
docker build --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg EMULATE_ARCH=${{ matrix.EMULATE_ARCH }} -f Dockerfile.${{ matrix.DOCKERFILE }} -t ffmpeg-builder-${{ matrix.name }} . | |
# Docker image build. | |
- name: 'Docker: building the FFmpeg binary.' | |
if: runner.os == 'Linux' | |
run: | | |
mkdir -p build | |
# Start the build environment for our requested target. | |
docker run -v $(pwd)/build:/build -e TARGET_OS=${{ matrix.TARGET_OS }} -e TARGET_BUILD_ARCH=${{ matrix.TARGET_ARCH }} ffmpeg-builder-${{ matrix.name }} | |
# Fix any permissions issues that may have arisen due to containerization. | |
sudo chown -R $USER:$USER build | |
# macOS Builds. | |
- name: 'macOS: building the FFmpeg binary.' | |
if: runner.os == 'macOS' | |
run: | | |
mkdir -p build | |
# Execute the build script. | |
cd build && SKIPINSTALL=yes VERBOSE=yes ../build-ffmpeg --build --enable-gpl-and-non-free | |
# Package our binaries for non-Windows operating systems. | |
- name: 'Linux and macOS: packaging the binary.' | |
if: matrix.DOCKERFILE != 'windows' | |
run: | | |
mkdir -p package/usr/local/bin/ | |
# Emulate the filesystem hierarchy so it's easily discoverable in a user's path environment variable. | |
cp build/workspace/bin/ffmpeg package/usr/local/bin/ffmpeg | |
# Now we package it all up. | |
tar -C package -zcvf ffmpeg-${{ matrix.name }}.tar.gz . | |
# Package our binaries for Windows. | |
- name: 'Windows: packaging the binary.' | |
if: matrix.DOCKERFILE == 'windows' | |
run: | | |
# Copy the binary we're looking for and we are done. | |
cp build/ffmpeg.exe . | |
# Upload the packaged asset as an artifact. | |
- name: 'Uploading the packaged asset.' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ffmpeg-${{ matrix.name }} | |
path: | | |
ffmpeg-${{ matrix.name }}.tar.gz | |
ffmpeg.exe | |