ci: Add custom patches and improve version detection
This commit is contained in:
+97
-28
@@ -6,6 +6,10 @@ on:
|
|||||||
description: 'Branch, Tag or Commit to build'
|
description: 'Branch, Tag or Commit to build'
|
||||||
required: false
|
required: false
|
||||||
default: 'master'
|
default: 'master'
|
||||||
|
apply_patches:
|
||||||
|
description: 'Apply custom patches (Boolean)'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
X264_VERSION: "0.161.3049"
|
X264_VERSION: "0.161.3049"
|
||||||
@@ -24,13 +28,21 @@ jobs:
|
|||||||
bits: [ 64, 32 ]
|
bits: [ 64, 32 ]
|
||||||
name: "Windows (${{ matrix.bits }}bit, ${{ matrix.type }}, ${{ matrix.license }}v${{ matrix.license_version}})"
|
name: "Windows (${{ matrix.bits }}bit, ${{ matrix.type }}, ${{ matrix.license }}v${{ matrix.license_version}})"
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "automation: Check out"
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
ref: "${{ github.event.inputs.ref }}"
|
|
||||||
submodules: "recursive"
|
submodules: "recursive"
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: "Gather Information"
|
|
||||||
|
- name: "automation: Copy patches to safe directory"
|
||||||
|
if: ${{ github.event.inputs.apply_patches == 'true' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [[ -d ./patches ]]; then
|
||||||
|
cp -a ./patches /tmp/
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: "automation: Gather Information"
|
||||||
id: data
|
id: data
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -60,15 +72,66 @@ jobs:
|
|||||||
echo "::set-output name=flags_type::--disable-static --enable-shared"
|
echo "::set-output name=flags_type::--disable-static --enable-shared"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Commit
|
- name: "ffmpeg: Check out ${{ github.event.inputs.ref }}"
|
||||||
echo "::set-output name=commit::$(git rev-parse --short=8 HEAD)"
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: "${{ github.event.inputs.ref }}"
|
||||||
|
submodules: "recursive"
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
# Version
|
- name: "automation: Detect version (and apply patches if necessary)"
|
||||||
VERSION=$(cat RELEASE)
|
id: version
|
||||||
echo "::set-output name=version_major::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\1/')"
|
shell: bash
|
||||||
echo "::set-output name=version_minor::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\2/')"
|
run: |
|
||||||
echo "::set-output name=version_patch::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\3/')"
|
# Detect Major.Minor.Patch version
|
||||||
- name: "Dependency: Packages"
|
VERSION=( $(cat RELEASE | sed -E 's/\./ /gi') )
|
||||||
|
VERSION_MAJOR=${VERSION[0]}
|
||||||
|
VERSION_MINOR=${VERSION[1]}
|
||||||
|
if (( ${#VERSION[@]} == 3 )); then
|
||||||
|
VERSION_PATCH=${VERSION[2]}
|
||||||
|
else
|
||||||
|
VERSION_PATCH=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMMIT="$(git rev-parse --short=8 HEAD)"
|
||||||
|
echo "FFmpeg v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${COMMIT}"
|
||||||
|
|
||||||
|
# Apply available patches
|
||||||
|
if [[ "${{ github.event.inputs.apply_patches}}" == "true" ]]; then
|
||||||
|
echo "Applying custom patches:"
|
||||||
|
|
||||||
|
declare -a PATCHES
|
||||||
|
if [[ "${{ github.event.inputs.ref }}" == "master" ]]; then
|
||||||
|
PATCHES[${#PATCHES[@]}]="master"
|
||||||
|
else
|
||||||
|
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
|
||||||
|
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}.${VERSION_MINOR}"
|
||||||
|
PATCHES[${#PATCHES[@]}]="${VERSION_MAJOR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for p in ${PATCHES[@]}; do
|
||||||
|
if [[ -d "/tmp/patches/${p}" ]]; then
|
||||||
|
echo " Found patches for ${p}:"
|
||||||
|
for f in /tmp/patches/${p}/*.patch; do
|
||||||
|
echo " ${f}..."
|
||||||
|
[ -e "$f" ] || continue
|
||||||
|
git apply "$f"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo " No patches for ${p}."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
VERSION_PATCH="${VERSION_PATCH}.patched"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set Outputs
|
||||||
|
echo "::set-output name=major::${VERSION_MAJOR}"
|
||||||
|
echo "::set-output name=minor::${VERSION_MINOR}"
|
||||||
|
echo "::set-output name=patch::${VERSION_PATCH}"
|
||||||
|
echo "::set-output name=commit::${COMMIT}"
|
||||||
|
|
||||||
|
- name: "dependency: cmake, make, pkg-config, mingw, nasm"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
@@ -80,7 +143,7 @@ jobs:
|
|||||||
nasm
|
nasm
|
||||||
|
|
||||||
# zlib-ng
|
# zlib-ng
|
||||||
- name: "Dependency: zlib (zlib-ng, v${{ env.ZLIB_NG_VERSION }}, Zlib license, shared)"
|
- name: "dependency: zlib (zlib-ng v${{ env.ZLIB_NG_VERSION }}, Zlib license, shared)"
|
||||||
id: zlib
|
id: zlib
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -105,8 +168,8 @@ jobs:
|
|||||||
sudo cp -a /tmp/zlib-ng/build/distrib/. /usr/${{ steps.data.outputs.cross_prefix }}
|
sudo cp -a /tmp/zlib-ng/build/distrib/. /usr/${{ steps.data.outputs.cross_prefix }}
|
||||||
|
|
||||||
# libx264 (FFmpeg 0.5 and up, arbitrarily limited to 1.0 because I'm lazy)
|
# libx264 (FFmpeg 0.5 and up, arbitrarily limited to 1.0 because I'm lazy)
|
||||||
- name: "Dependency: x264 (v${{ env.X264_VERSION }}, GPLv2, shared)"
|
- name: "dependency: x264 v${{ env.X264_VERSION }} (GPLv2, shared)"
|
||||||
if: ${{ (steps.data.outputs.version_major >= 1) && startsWith(matrix.license, 'GPL') }}
|
if: ${{ (steps.version.outputs.major >= 1) && startsWith(matrix.license, 'GPL') }}
|
||||||
id: x264
|
id: x264
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -116,8 +179,8 @@ jobs:
|
|||||||
echo "::set-output name=flags::--enable-libx264"
|
echo "::set-output name=flags::--enable-libx264"
|
||||||
|
|
||||||
# NVIDIA Codec Headers (FFmpeg 3.0 and up)
|
# NVIDIA Codec Headers (FFmpeg 3.0 and up)
|
||||||
- name: "Dependency: NVIDIA Codec Headers (v${{ env.FFNVCODEC_VERSION }}, MIT, shared)"
|
- name: "dependency: NVIDIA Codec Headers v${{ env.FFNVCODEC_VERSION }} (MIT, shared)"
|
||||||
if: ${{ steps.data.outputs.version_major >= 3 }}
|
if: ${{ steps.version.outputs.major >= 3 }}
|
||||||
id: ffnvcodec
|
id: ffnvcodec
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -127,24 +190,24 @@ jobs:
|
|||||||
sudo make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }} install
|
sudo make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }} install
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
if (( "${{ steps.data.outputs.version_major }}" >= 4 )); then
|
if (( "${{ steps.version.outputs.major }}" >= 4 )); then
|
||||||
echo "::set-output name=flags::--enable-ffnvcodec --enable-nvdec --enable-cuvid --enable-nvenc"
|
echo "::set-output name=flags::--enable-ffnvcodec --enable-nvdec --enable-cuvid --enable-nvenc"
|
||||||
elif (( "${{ steps.data.outputs.version_major }}" >= 3 )); then
|
elif (( "${{ steps.version.outputs.major }}" >= 3 )); then
|
||||||
if (( "${{ steps.data.outputs.version_minor }}" >= 2 )); then
|
if (( "${{ steps.version.outputs.minor }}" >= 2 )); then
|
||||||
# 3.2+ has cuda, cuvid, nvenc
|
# 3.2+ has cuda, cuvid, nvenc
|
||||||
echo "::set-output name=flags::--enable-cuvid --enable-nvenc"
|
echo "::set-output name=flags::--enable-cuvid --enable-nvenc"
|
||||||
elif (( "${{ steps.data.outputs.version_minor }}" >= 1 )); then
|
elif (( "${{ steps.version.outputs.minor }}" >= 1 )); then
|
||||||
# 3.1 has cuda, nvenc
|
# 3.1 has cuda, nvenc
|
||||||
echo "::set-output name=flags::--enable-nvenc"
|
echo "::set-output name=flags::--enable-nvenc"
|
||||||
elif (( "${{ steps.data.outputs.version_minor }}" >= 0 )); then
|
elif (( "${{ steps.version.outputs.minor }}" >= 0 )); then
|
||||||
# 3.0 has nvenc
|
# 3.0 has nvenc
|
||||||
echo "::set-output name=flags::--enable-nvenc"
|
echo "::set-output name=flags::--enable-nvenc"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# AMD AMF (FFmpeg 4.0 and up)
|
# AMD AMF (FFmpeg 4.0 and up)
|
||||||
- name: "Dependency: AMD AMF (v${{ env.AMF_VERSION }}, MIT, shared)"
|
- name: "dependency: AMD AMF (v${{ env.AMF_VERSION }}, MIT, shared)"
|
||||||
if: ${{ steps.data.outputs.version_major >= 4 }}
|
if: ${{ steps.version.outputs.major >= 4 }}
|
||||||
id: amf
|
id: amf
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -153,12 +216,12 @@ jobs:
|
|||||||
sudo cp -R amf/public/include/ /usr/${{ steps.data.outputs.cross_prefix }}/include/AMF
|
sudo cp -R amf/public/include/ /usr/${{ steps.data.outputs.cross_prefix }}/include/AMF
|
||||||
popd
|
popd
|
||||||
|
|
||||||
if (( "${{ steps.data.outputs.version_major }}" >= 4 )); then
|
if (( "${{ steps.version.outputs.major }}" >= 4 )); then
|
||||||
echo "::set-output name=flags::--enable-amf"
|
echo "::set-output name=flags::--enable-amf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure FFmpeg
|
# Configure FFmpeg
|
||||||
- name: "Configure"
|
- name: "ffmpeg: Configure"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
export PKG_CONFIG_PATH=/usr/${{ steps.data.outputs.cross_prefix }}/lib/pkgconfig:${PKG_CONFIG_PATH}
|
export PKG_CONFIG_PATH=/usr/${{ steps.data.outputs.cross_prefix }}/lib/pkgconfig:${PKG_CONFIG_PATH}
|
||||||
@@ -179,13 +242,19 @@ jobs:
|
|||||||
${{ steps.x264.outputs.flags }} \
|
${{ steps.x264.outputs.flags }} \
|
||||||
${{ steps.ffnvcodec.outputs.flags }} \
|
${{ steps.ffnvcodec.outputs.flags }} \
|
||||||
${{ steps.amf.outputs.flags }}
|
${{ steps.amf.outputs.flags }}
|
||||||
- name: "Compile"
|
|
||||||
|
- name: "ffmpeg: Compile"
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
make -j 4
|
make -j 4
|
||||||
|
|
||||||
|
- name: "ffmpeg: Install"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
make install
|
make install
|
||||||
- name: "Upload Artifacts"
|
|
||||||
|
- name: "automation: Upload Artifacts"
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: ffmpeg-${{ matrix.bits }}-${{ matrix.type }}-${{ matrix.license }}v${{ matrix.license_version }}-${{ steps.data.outputs.version_major }}.${{ steps.data.outputs.version_minor }}.${{ steps.data.outputs.version_patch }}-${{ steps.data.outputs.commit }}
|
name: ffmpeg-${{ matrix.bits }}-${{ matrix.type }}-${{ matrix.license }}v${{ matrix.license_version }}-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}-${{ steps.version.outputs.commit }}
|
||||||
path: distrib
|
path: distrib
|
||||||
|
|||||||
@@ -81,12 +81,22 @@ jobs:
|
|||||||
|
|
||||||
if ${BRANCH_REQUIRES_UPDATE}; then
|
if ${BRANCH_REQUIRES_UPDATE}; then
|
||||||
git push --follow-tags --set-upstream origin ${d}
|
git push --follow-tags --set-upstream origin ${d}
|
||||||
curl \
|
|
||||||
|
# Trigger build without custom patches
|
||||||
|
curl -s --show-error \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \
|
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \
|
||||||
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
||||||
|
|
||||||
|
# Trigger build with custom patches
|
||||||
|
curl -s --show-error \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\",\"apply_patches\":\"true\"}}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
- name: "Only trigger build on manual push"
|
- name: "Only trigger build on manual push"
|
||||||
@@ -97,10 +107,19 @@ jobs:
|
|||||||
BRANCHES[${#BRANCHES[@]}]="master"
|
BRANCHES[${#BRANCHES[@]}]="master"
|
||||||
|
|
||||||
for d in ${BRANCHES[@]}; do
|
for d in ${BRANCHES[@]}; do
|
||||||
curl \
|
# Trigger build without custom patches
|
||||||
|
curl -s --show-error \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \
|
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\"}}" \
|
||||||
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
||||||
|
|
||||||
|
# Trigger build with custom patches
|
||||||
|
curl -s --show-error \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
-d "{\"ref\":\"${{ github.ref }}\",\"inputs\":{\"ref\":\"${d}\",\"apply_patches\":\"true\"}}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user