143 lines
4.4 KiB
YAML

name: build-ci
on:
push:
branches: [ "*" ]
tags: [ "*" ]
paths-ignore:
- "**.7z"
pull_request:
branches: [ main ]
env:
FFMPEG_VER: "6.0"
jobs:
FFmpeg:
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
CCACHE_CPP2: "yes"
CCACHE_SLOPPINESS: "time_macros"
CC: "ccache clang"
CXX: "ccache clang++"
OBJC: "clang"
runs-on: macos-latest
steps:
- name: Checkout
run: |
git clone -b n${FFMPEG_VER} https://git.ffmpeg.org/ffmpeg.git --depth 1
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/Library/Caches/ccache
key: ${{ runner.os }}-macos-${{ github.sha }}
restore-keys: |
${{ runner.os }}-macos-
- name: Install dependencies
run: |
brew install p7zip ccache nasm
- name: Build FFMPEG
run: |
export PATH="/usr/local/opt/ccache/libexec:$PATH"
mkdir -p ffmpeg/build
cd ffmpeg/build
x86path=$(pwd)/x86_64
armpath=$(pwd)/arm64
# Build for x86_64
mkdir -p $x86path/install
cd $x86path
# The included lzma is built for 10.15 can generates linker warnings
../../configure --enable-cross-compile --arch=x86_64 \
--cc="${CC} -arch x86_64" --cxx="${CXX} -arch x86_64" --enable-shared --disable-static --disable-doc \
--disable-lzma --disable-xlib
make -j4
make install DESTDIR=$x86path/install
# Build for arm64
mkdir -p $armpath/install
cd $armpath
# The included lzma is built for 10.15 can generates linker warnings
../../configure --enable-cross-compile --arch=arm64 \
--cc="${CC} -arch arm64" --cxx="${CXX} -arch arm64" --enable-shared --disable-static --disable-doc \
--disable-lzma --disable-xlib
make -j4
make install DESTDIR=$armpath/install
- name: Create universal build
run: |
cd ffmpeg/build
x86path=$(pwd)/x86_64
armpath=$(pwd)/arm64
universalpath=$(pwd)/ffmpeg-${FFMPEG_VER}
# Fix dylibs to be path-independent.
for dylib in $(find $(pwd) -name '*.dylib'); do
# Fix ID.
id_path=$(otool -D $dylib | sed -n '2 p')
fixed_id_path="@rpath/"`basename $id_path`
install_name_tool -id $fixed_id_path $dylib
# Fix dependency paths.
for path in $(otool -L $dylib | grep \t | cut -d' ' -f1 | xargs); do
if [[ $path = /usr/local/lib* ]]; then
fixed_path="@rpath/"`basename $path`
install_name_tool -change $path $fixed_path $dylib
fi
done
done
mkdir -p $universalpath
for f in $(find $x86path/install); do
subpath=${f#$x86path/install}
dest=$universalpath$subpath
if [ -d "$f" ]; then
mkdir -p "$dest"
elif [ -L "$f" ]; then
ln -s $(readlink "$f") "$dest"
elif [[ ":$f:" == *"/bin/"* ]] || [[ $f == *.a ]] || [[ $f == *.dylib ]]; then
lipo -create -output "$dest" "$x86path/install$subpath" "$armpath/install$subpath"
else
cp "$f" "$dest"
fi
done
7z a "ffmpeg-${FFMPEG_VER}.7z" ffmpeg-${FFMPEG_VER}/
- name: Pack
run: |
# move the compiled archive into the artifacts directory to be uploaded
mkdir -p artifacts/ffmpeg
mv "ffmpeg/build/ffmpeg-${FFMPEG_VER}.7z" artifacts/ffmpeg
- name: Upload
uses: actions/upload-artifact@v3
with:
name: macos
path: |
artifacts/
PR:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [FFmpeg]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: ~/
- name: Copy Artifacts
run: cp -r ~/macos/* ./
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
delete-branch: true
title: '[Auto] The bump by Github Actions'
commit-message: |
[Auto] Bumps
- FFmpeg ${{ env.FFMPEG_VER }}
body: |
Bumps
- FFmpeg ${{ env.FFMPEG_VER }}