Skip to content

ci: fix generated dist #496

ci: fix generated dist

ci: fix generated dist #496

Workflow file for this run

---
name: CI
permissions:
contents: read
on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
push:
branches:
- master
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
FREEBSD_CLANG_VERSION: 19
LINUX_GCC_VERSION: 12
MACOSX_DEPLOYMENT_TARGET: 13.0
jobs:
build:
name: Build ${{ matrix.build }} (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# name: ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}
- name: Linux-x86_64
os: ubuntu-22.04
arch: x86_64
generator: "Unix Makefiles"
shell: bash
build: ALL
- name: Linux-aarch64
os: ubuntu-22.04
arch: aarch64
generator: "Unix Makefiles"
shell: bash
target: aarch64-linux-gnu
build: ALL
- name: Linux-ppc64le
os: ubuntu-22.04
arch: powerpc64le
generator: "Unix Makefiles"
shell: bash
target: powerpc64le-linux-gnu
build: FFMPEG # https://github.com/boostorg/context/issues/311
- name: Darwin-x86_64
os: macos-13
arch: x86_64
generator: "Unix Makefiles"
shell: bash
target: x86_64-apple-macosx
build: ALL
- name: Darwin-arm64
os: macos-14
arch: aarch64
generator: "Unix Makefiles"
shell: bash
target: arm64-apple-macosx
build: ALL
- name: Windows-AMD64
os: windows-2022
arch: x86_64
generator: "MSYS Makefiles"
shell: msys2 {0}
msystem: ucrt64
toolchain: ucrt-x86_64
build: BOOST
- name: Windows-AMD64
os: windows-2022
arch: x86_64
generator: "MSYS Makefiles"
shell: msys2 {0}
msystem: ucrt64
toolchain: ucrt-x86_64
build: FFMPEG
- name: Windows-ARM64
os: windows-11-arm
arch: aarch64
generator: "MSYS Makefiles"
shell: msys2 {0}
msystem: clangarm64
toolchain: clang-aarch64
build: ALL
- name: FreeBSD-amd64
os: ubuntu-latest
arch: x86_64
bsd_release: '14.3'
generator: "Unix Makefiles"
shell: freebsd {0}
build: ALL
- name: FreeBSD-aarch64
os: ubuntu-latest # ubuntu-24.04-arm is slower with the FreeBSD VM
arch: aarch64
bsd_release: '14.3'
generator: "Unix Makefiles"
shell: freebsd {0}
build: ALL
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare Dependencies Linux
id: cross_compile
if: runner.os == 'Linux' && !startsWith(matrix.shell, 'freebsd')
run: |
echo "::group::distro detection"
# detect dist name like bionic, focal, etc
dist_name=$(lsb_release -cs)
ubuntu_version=$(lsb_release -rs)
ubuntu_major_version=${ubuntu_version%%.*}
echo "detected dist name: $dist_name"
echo "detected ubuntu version: $ubuntu_version"
echo "detected ubuntu major version: $ubuntu_major_version"
echo "::endgroup::"
echo "::group::install aptitude"
sudo apt-get update # must run before changing sources file
sudo apt-get install -y \
aptitude
echo "::endgroup::"
if [[ $ubuntu_major_version -le 20 ]]; then
# activate mesa backport PPA to ensure ffmpeg builds with vaSyncBuffer()
# (via libva 2.9.0 or later)
sudo add-apt-repository ppa:kisak/turtle -y
fi
echo "::group::dependencies prep"
dependencies=(
"autoconf"
"automake"
"build-essential"
"cmake"
"git-core"
"libass-dev"
"libfreetype6-dev"
"libgnutls28-dev"
"libmp3lame-dev"
"libnuma-dev"
"libopus-dev"
"libsdl2-dev"
"libtool"
"libvorbis-dev"
"libxcb1-dev"
"libxcb-shm0-dev"
"libxcb-xfixes0-dev"
"make"
"meson"
"nasm"
"ninja-build"
"pkg-config"
"texinfo"
"wget"
"zlib1g-dev"
)
package_arch="amd64"
cross_compile=false
package_arch=$(dpkg --print-architecture)
if [[ ${{ matrix.arch }} == "aarch64" ]]; then
dependencies+=("crossbuild-essential-arm64")
dependencies+=("gcc-${LINUX_GCC_VERSION}-aarch64-linux-gnu")
dependencies+=("g++-${LINUX_GCC_VERSION}-aarch64-linux-gnu")
cross_compile=true
package_arch="arm64"
elif [[ ${{ matrix.arch }} == "powerpc64le" ]]; then
dependencies+=("crossbuild-essential-ppc64el")
dependencies+=("gcc-${LINUX_GCC_VERSION}-powerpc64le-linux-gnu")
dependencies+=("g++-${LINUX_GCC_VERSION}-powerpc64le-linux-gnu")
cross_compile=true
package_arch="ppc64el"
else
dependencies+=("gcc-${LINUX_GCC_VERSION}")
dependencies+=("g++-${LINUX_GCC_VERSION}")
fi
echo "cross compiling: $cross_compile"
echo "package architecture: $package_arch"
dependencies+=(
"libva-dev:$package_arch"
"libva-glx2:$package_arch"
"libgl1:$package_arch"
"libglx0:$package_arch"
)
echo "::group::apt sources"
mirror="https://ports.ubuntu.com/ubuntu-ports"
# source file changed in 24.04
if [[ $ubuntu_major_version -ge 24 ]]; then
source_file="/etc/apt/sources.list.d/ubuntu.sources"
extra_sources=$(cat <<- VAREOF
Types: deb
URIs: mirror+file:/etc/apt/apt-mirrors.txt
Suites: ${dist_name} ${dist_name}-updates ${dist_name}-backports ${dist_name}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: $(dpkg --print-architecture)
Types: deb
URIs: ${mirror}
Suites: ${dist_name} ${dist_name}-updates ${dist_name}-backports ${dist_name}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: ${package_arch}
VAREOF
)
else
source_file="/etc/apt/sources.list"
extra_sources=$(cat <<- VAREOF
deb [arch=${package_arch}] ${mirror} ${dist_name} main restricted
deb [arch=${package_arch}] ${mirror} ${dist_name}-updates main restricted
deb [arch=${package_arch}] ${mirror} ${dist_name} universe
deb [arch=${package_arch}] ${mirror} ${dist_name}-updates universe
deb [arch=${package_arch}] ${mirror} ${dist_name} multiverse
deb [arch=${package_arch}] ${mirror} ${dist_name}-updates multiverse
deb [arch=${package_arch}] ${mirror} ${dist_name}-backports main restricted universe multiverse
deb [arch=${package_arch}] ${mirror} ${dist_name}-security main restricted
deb [arch=${package_arch}] ${mirror} ${dist_name}-security universe
deb [arch=${package_arch}] ${mirror} ${dist_name}-security multiverse
VAREOF
)
fi
if [[ ${cross_compile} == true ]]; then
# print original sources
echo "original sources:"
sudo cat ${source_file}
echo "----"
sudo dpkg --add-architecture ${package_arch}
if [[ $ubuntu_major_version -ge 24 ]]; then
echo "$extra_sources" | sudo tee ${source_file} > /dev/null
else
# fix original sources
sudo sed -i -e "s#deb mirror#deb [arch=amd64] mirror#g" ${source_file}
echo "$extra_sources" | sudo tee -a ${source_file} > /dev/null
fi
echo "----"
echo "new sources:"
sudo cat ${source_file}
echo "----"
fi
echo "::endgroup::"
echo "::group::output"
echo "CROSS_COMPILE=${cross_compile}"
echo "CROSS_COMPILE=${cross_compile}" >> "${GITHUB_OUTPUT}"
echo "DEPENDENCIES=${dependencies[@]}"
echo "DEPENDENCIES=${dependencies[@]}" >> "${GITHUB_OUTPUT}"
echo "PKG_CONFIG_SYSROOT_DIR=${pkg_config_sysroot_dir}"
echo "PKG_CONFIG_SYSROOT_DIR=${pkg_config_sysroot_dir}" >> "${GITHUB_ENV}"
echo "PKG_CONFIG_PATH=${pkg_config_sysroot_dir}/pkgconfig"
echo "PKG_CONFIG_PATH=${pkg_config_sysroot_dir}/pkgconfig" >> "${GITHUB_ENV}"
if [[ ${cross_compile} == false ]]; then
echo "CC=gcc-${LINUX_GCC_VERSION}"
echo "CC=gcc-${LINUX_GCC_VERSION}" >> "${GITHUB_ENV}"
echo "CXX=g++-${LINUX_GCC_VERSION}"
echo "CXX=g++-${LINUX_GCC_VERSION}" >> "${GITHUB_ENV}"
fi
echo "::endgroup::"
- name: Setup Dependencies Linux
if: runner.os == 'Linux' && !startsWith(matrix.shell, 'freebsd')
run: |
echo "::group::apt update"
sudo apt-get update
echo "::endgroup::"
echo "::group::install dependencies"
sudo aptitude install -y --without-recommends ${{ steps.cross_compile.outputs.DEPENDENCIES }}
echo "::endgroup::"
- name: Setup Dependencies MacOS
if: runner.os == 'macOS'
run: |
dependencies=(
"automake"
"fdk-aac"
"git"
"lame"
"libass"
"libtool"
"libvorbis"
"libvpx"
"nasm"
"ninja"
"opus"
"pkg-config"
"sdl"
"shtool"
"texi2html"
"theora"
"wget"
"xvid"
)
brew install ${dependencies[@]}
- name: Setup msys2 Windows
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
- name: Update Windows dependencies
env:
MSYSTEM: ${{ matrix.msystem }}
TOOLCHAIN: ${{ matrix.toolchain }}
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
# variables
declare -A pinned_deps
# nothing to pin currently
dependencies=(
"diffutils"
"git"
"make"
"patch"
"pkg-config"
"mingw-w64-${TOOLCHAIN}-binutils"
"mingw-w64-${TOOLCHAIN}-cmake"
"mingw-w64-${TOOLCHAIN}-gcc"
"mingw-w64-${TOOLCHAIN}-make"
"mingw-w64-${TOOLCHAIN}-nasm"
"mingw-w64-${TOOLCHAIN}-ninja"
"mingw-w64-${TOOLCHAIN}-onevpl"
)
# do not modify below this line
ignore_packages=()
tarballs=""
for pkg in "${!pinned_deps[@]}"; do
ignore_packages+=("${pkg}")
version="${pinned_deps[$pkg]}"
tarball="${pkg}-${version}-any.pkg.tar.zst"
# download and install working version
wget "https://repo.msys2.org/mingw/${MSYSTEM}/${tarball}"
tarballs="${tarballs} ${tarball}"
done
# Create the ignore string for pacman
ignore_list=$(IFS=,; echo "${ignore_packages[*]}")
# install pinned dependencies
if [ -n "$tarballs" ]; then
pacman -U --noconfirm "${tarballs}"
fi
# Only add --ignore if we have packages to ignore
if [ -n "$ignore_list" ]; then
pacman -Syu --noconfirm --ignore="${ignore_list}" "${dependencies[@]}"
else
pacman -Syu --noconfirm "${dependencies[@]}"
fi
- name: Debug msys2.CMD
if: runner.os == 'Windows'
run: |
echo "MSYS2_ROOT=${{ runner.temp }}/msys64" >> "${GITHUB_ENV}"
cat "${{ runner.temp }}/setup-msys2/msys2.CMD"
- name: Get submodule history
shell: bash
run: |
# x265.pc will not be installed if their cmake cannot detect the latest tag
# SVT-AV1 cannot determine version if the git history is not available
for repo in "x265_git" "SVT-AV1"; do
cd "${GITHUB_WORKSPACE}/third-party/FFmpeg/${repo}"
git fetch --tags --force origin
done
- name: Get Processor Count
id: processor_count
shell: bash
run: |
if [ "${{ runner.os }}" = 'macOS' ]; then
PROCESSOR_COUNT=$(sysctl -n hw.ncpu)
else
PROCESSOR_COUNT=$(nproc)
fi
echo "PROCESSOR_COUNT=${PROCESSOR_COUNT}" >> "${GITHUB_OUTPUT}"
echo "PROCESSOR_COUNT: ${PROCESSOR_COUNT}"
- name: Setup FreeBSD
if: startsWith(matrix.shell, 'freebsd')
uses: vmactions/[email protected]
with:
arch: ${{ matrix.arch }}
cpu: ${{ steps.processor_count.outputs.PROCESSOR_COUNT }}
prepare: |
pkg install -y \
devel/autoconf \
devel/automake \
devel/cmake \
devel/git \
devel/gmake \
devel/llvm${{ env.FREEBSD_CLANG_VERSION }} \
devel/nasm \
devel/ninja \
devel/pkgconf \
multimedia/libass \
multimedia/libv4l \
multimedia/libva \
multimedia/v4l_compat \
print/freetype2 \
security/gnutls \
shells/bash \
x11/libx11 \
x11/libxcb \
x11/libXfixes
# create symlink for shebang bash compatibility
ln -s /usr/local/bin/bash /bin/bash
release: ${{ matrix.bsd_release }}
run: |
git config --global --add safe.directory "*"
sync: nfs
- name: Setup ENV
id: root
run: |
set -e
cd $GITHUB_WORKSPACE
echo "ROOT_PATH=$PWD" >> "${GITHUB_ENV}"
MAKE_CMD="make"
if [ "${{ startsWith(matrix.shell, 'freebsd') }}" = true ]; then
# use gmake on FreeBSD instead of make
MAKE_CMD="gmake"
fi
echo "MAKE_CMD=${MAKE_CMD}" >> "${GITHUB_ENV}"
- name: Setup cross compilation
id: cross
if: matrix.target != ''
run: |
set -e
cd $GITHUB_WORKSPACE
TOOLCHAIN=${{ env.ROOT_PATH }}/cmake/toolchains/${{ matrix.target }}.cmake
# fail if file does not exist
if [ ! -f $TOOLCHAIN ]; then
echo "Toolchain file not found: $TOOLCHAIN"
exit 1
fi
echo "CMAKE_TOOLCHAIN_FILE=$TOOLCHAIN" >> "${GITHUB_ENV}"
if [[ ${{ runner.os }} == 'Linux' ]]; then
echo "CCPREFIX=/usr/bin/${{ matrix.target }}-" >> "${GITHUB_ENV}"
fi
- name: Configure
run: |
set -e
cd $GITHUB_WORKSPACE
if [ "${{ startsWith(matrix.shell, 'freebsd') }}" = true ]; then
export CC=$(which clang${{ env.FREEBSD_CLANG_VERSION }})
export CXX=$(which clang++${{ env.FREEBSD_CLANG_VERSION }})
# make sure they exist
if [ ! -f "$CC" ]; then
echo "Compiler not found: $CC"
exit 1
fi
if [ ! -f "$CXX" ]; then
echo "Compiler not found: $CXX"
exit 1
fi
fi
mkdir -p ./build/dist
cmake \
-B build \
-S . \
-G "${{ matrix.generator }}" \
-DBUILD_ALL=OFF \
-DBUILD_${{ matrix.build }}=ON \
-DCMAKE_TOOLCHAIN_FILE=${{ env.CMAKE_TOOLCHAIN_FILE }} \
-DCMAKE_INSTALL_PREFIX="${{ env.ROOT_PATH }}/build/dist" \
-DPARALLEL_BUILDS=${{ steps.processor_count.outputs.PROCESSOR_COUNT || 1 }}
- name: Build
run: |
set -e
cd $GITHUB_WORKSPACE
${{ env.MAKE_CMD }} -C build --jobs=${{ steps.processor_count.outputs.PROCESSOR_COUNT || 1 }}
- name: Install
run: |
set -e
cd $GITHUB_WORKSPACE
${{ env.MAKE_CMD }} -C build install
- name: Debug logs
if: >-
always() &&
matrix.build == 'FFMPEG'
shell: bash
run: |
echo "::group::x264 config.log"
cat ./third-party/FFmpeg/x264/config.log || true
echo "::endgroup::"
echo "::group::FFmpeg config.log"
cat ./build/generated-src/FFmpeg/ffbuild/config.log || true
echo "::endgroup::"
- name: Debug build directory
if: always()
shell: bash
run: ls -R ./build
- name: Debug build/dist directory
if: always()
shell: bash
run: ls -R ./build/dist
- name: Cleanup
shell: bash
run: |
rm -f -r ./build/dist/share
rm -f -r ./build/dist/lib/cmake
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{ matrix.name }}-${{ matrix.build }}
path: ./build/dist
update_dist:
# only the commit is conditional, so the rest of the job can be verified on PRs
name: Update dist
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout dist
uses: actions/checkout@v4
with:
ref: dist
path: dist
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
- name: Cleanup
run: |
rm -rf dist/*
mkdir -p dist/dist
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist/dist
- name: Arrange dist
working-directory: dist/dist
run: |
for dir in */; do
dir="${dir%/}"
new_name="${dir%-*}"
if [[ "${dir}" != "${new_name}" ]]; then
if [[ -d "${new_name}" ]]; then
rsync -a "${dir}/" "${new_name}/"
rm -rf "${dir}"
else
mv "${dir}" "${new_name}"
fi
fi
done
- name: Debug dist directory
run: ls -R dist
- name: Show git diff
working-directory: dist/dist
run: |
git add --all
echo "Changed files:" >> "${GITHUB_STEP_SUMMARY}"
git diff --name-only >> "${GITHUB_STEP_SUMMARY}"
- name: Extract first line of commit message
id: commit_message
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
FIRST_LINE=$(echo "${COMMIT_MESSAGE}" | head -n 1)
echo "first_line=$FIRST_LINE"
echo "first_line=$FIRST_LINE" >> "${GITHUB_OUTPUT}"
- name: Commit dist
if: >-
startsWith(github.repository, 'LizardByte/') &&
github.ref == 'refs/heads/master' &&
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: actions-js/[email protected]
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ secrets.GH_BOT_NAME }}
directory: dist
branch: dist
force: false
message: "${{ steps.commit_message.outputs.first_line }}"