Add CD action for macOS platform #198
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
name: Review | |
on: | |
pull_request_target: | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
concurrency: | |
group: "review-${{ github.event.pull_request.number }}" | |
cancel-in-progress: true | |
steps: | |
- name: Checkout target branch code (using pull_request_target) | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Fetch and checkout PR branch | |
run: | | |
git remote add pr_origin https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git | |
git fetch pr_origin ${{ github.event.pull_request.head.ref }}:pr_branch | |
git checkout pr_branch | |
- name: Print current branch and commit hash | |
run: | | |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" | |
echo "Current commit hash: $(git rev-parse HEAD)" | |
- name: Checkout BMF repository (specific branch) | |
run: | | |
sudo apt update | |
sudo apt install -y make git pkg-config libssl-dev cmake binutils-dev libgoogle-glog-dev gcc g++ golang wget libgl1 | |
sudo apt install -y nasm yasm libx264-dev libx265-dev libnuma-dev | |
sudo apt install -y python3.9 python3-dev python3-pip libsndfile1 libsndfile1-dev | |
git clone https://github.com/JackLau1222/bmf.git | |
- name: Cache FFmpeg build | |
uses: actions/cache@v3 | |
with: | |
path: | | |
ffmpeg | |
key: ${{ runner.os }}-ffmpeg-${{ hashFiles('bmf/scripts/build_ffmpeg.sh') }} | |
restore-keys: | | |
${{ runner.os }}-ffmpeg- | |
- name: Cache BMF build | |
uses: actions/cache@v3 | |
with: | |
path: bmf/output/ | |
key: ${{ runner.os }}-bmf-${{ hashFiles('bmf/build.sh') }} | |
restore-keys: | | |
${{ runner.os }}-bmf- | |
- name: Compile FFmpeg if not cached | |
run: | | |
if [ ! -d "$(pwd)/ffmpeg" ]; then | |
echo "FFmpeg not found, starting build..." | |
wget https://ffmpeg.org/releases/ffmpeg-5.1.6.tar.bz2 && tar xjvf ffmpeg-5.1.6.tar.bz2 | |
(cd ffmpeg-5.1.6 && ./configure --pkg-config-flags=--static --enable-shared --disable-static --extra-libs=-lpthread --extra-libs=-lm --enable-gpl --enable-nonfree --enable-libx264 --enable-libx265 --prefix=../ffmpeg) | |
(cd ffmpeg-5.1.6 && make -j$(nproc) && make install) | |
else | |
echo "FFmpeg is already installed, skipping build." | |
fi | |
echo "FFMPEG_ROOT_PATH=$(pwd)/ffmpeg" >> $GITHUB_ENV | |
- name: Set up BMF if not cached | |
run: | | |
if [ ! -d "$(pwd)/bmf/output/" ]; then | |
(cd bmf && git checkout fork_by_oc && ./build.sh) | |
else | |
echo "BMF is already installed, skipping build." | |
fi | |
echo "BMF_ROOT_PATH=$(pwd)/bmf/output/bmf" >> $GITHUB_ENV | |
- name: Set up Qt | |
run: | | |
sudo apt-get install -y qt5-qmake qtbase5-dev qtchooser qtbase5-dev-tools cmake build-essential | |
- name: Build with CMake | |
run: | | |
export PATH=$PATH:$FFMPEG_ROOT_PATH/bin | |
(cd src && cmake -B build && cd build && make -j$(nproc)) | |
- name: Copy libs | |
run: | | |
export LD_LIBRARY_PATH=$FFMPEG_ROOT_PATH/lib/:$BMF_ROOT_PATH/lib | |
export LIBRARY_PATH=$FFMPEG_ROOT_PATH/lib/:$BMF_ROOT_PATH/lib | |
# linuxdeployqt | |
sudo apt-get -y install git g++ libgl1-mesa-dev | |
git clone https://github.com/probonopd/linuxdeployqt.git | |
# Then build in Qt Creator, or use | |
export PATH=$(readlink -f /tmp/.mount_QtCreator-*-x86_64/*/gcc_64/bin/):$PATH | |
(cd linuxdeployqt && qmake && make && sudo make install) | |
# patchelf | |
wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 | |
tar xf patchelf-0.9.tar.bz2 | |
( cd patchelf-0.9/ && ./configure && make && sudo make install ) | |
# appimage | |
sudo wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool | |
sudo chmod a+x /usr/local/bin/appimagetool | |
(linuxdeployqt/bin/linuxdeployqt ./src/build/OpenConverter -appimage) | |
continue-on-error: true | |
- name: Copy runtime | |
run: | | |
cp $FFMPEG_ROOT_PATH/lib/libswscale.so.6 src/build/lib | |
cp $FFMPEG_ROOT_PATH/lib/libavfilter.so.8 src/build/lib | |
cp $FFMPEG_ROOT_PATH/lib/libpostproc.so.56 src/build/lib | |
cp $BMF_ROOT_PATH/lib/libbuiltin_modules.so src/build/lib | |
cp $BMF_ROOT_PATH/BUILTIN_CONFIG.json src/build | |
touch src/build/activate_env.sh | |
echo export LD_LIBRARY_PATH="./lib" >> src/build/activate_env.sh | |
# Step to package the build directory | |
- name: Create tar.gz package | |
run: | | |
BUILD_DIR="src/build" | |
PACKAGE_NAME="OpenConverter_Linux_x86.tar.gz" | |
OUTPUT_DIR="OpenConverter_Linux_x86" | |
mkdir -p $OUTPUT_DIR | |
cp -r $BUILD_DIR/* $OUTPUT_DIR/ | |
tar -czvf $PACKAGE_NAME -C $OUTPUT_DIR . | |
rm -rf $OUTPUT_DIR | |
# Step to upload the tar.gz package as an artifact | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: OpenConverter_Linux_x86 | |
path: OpenConverter_Linux_x86.tar.gz | |
- name: Setup tmate session | |
if: ${{ failure() }} | |
uses: mxschmitt/action-tmate@v3 | |
- name: Finish | |
run: echo "Release upload complete" |