forked from homebridge/ffmpeg-for-homebridge
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (96 loc) · 3.55 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# 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