Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
name: Build Untrunc (Multi-Arch)

on:
push:
branches: [ "master", "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "master", "main" ]
workflow_dispatch:

jobs:
get-ffmpeg-version:
name: Get Latest FFmpeg Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get latest FFmpeg release
id: get-version
run: |
VERSION=$(curl -s https://ffmpeg.org/releases/ | grep -oP 'ffmpeg-\K[0-9]+\.[0-9]+(\.[0-9]+)?' | sort -V | tail -1)
echo "Latest FFmpeg version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

build-linux:
name: Linux (${{ matrix.arch }})
runs-on: ubuntu-latest
needs: get-ffmpeg-version
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
image: debian:12-slim
- arch: arm64
platform: linux/arm64
image: debian:12-slim
- arch: armv7
platform: linux/arm/v7
image: debian:12-slim
- arch: i386
platform: linux/386
image: i386/debian:12-slim

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Cache compiled FFmpeg
id: cache-ffmpeg
uses: actions/cache@v4
with:
path: ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}
key: ffmpeg-built-linux-${{ matrix.arch }}-${{ needs.get-ffmpeg-version.outputs.version }}

- name: Build FFmpeg inside Docker
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
docker run --rm --platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
${{ matrix.image }} /bin/bash -c "
apt-get update && \
apt-get install -y g++ make wget nasm xz-utils && \
wget -q -O /tmp/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz \
https://www.ffmpeg.org/releases/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz && \
tar xf /tmp/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz && \
mv ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}/VERSION \
ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}/VERSION.bak && \
cd ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }} && \
./configure --disable-doc --disable-programs \
--disable-everything --enable-decoders --disable-vdpau --enable-demuxers --enable-protocol=file \
--disable-avdevice --disable-swresample --disable-swscale --disable-avfilter \
--disable-xlib --disable-vaapi --disable-zlib --disable-bzlib --disable-lzma && \
make -j\$(nproc) && \
chown -R \$(stat -c '%u:%g' /workspace) /workspace/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}
"

- name: Build untrunc inside Docker
run: |
docker run --rm --platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
${{ matrix.image }} /bin/bash -c "
apt-get update && \
apt-get install -y g++ make && \
make FF_VER=${{ needs.get-ffmpeg-version.outputs.version }} IS_RELEASE=1 && \
mv untrunc untrunc-linux-${{ matrix.arch }}
"

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: untrunc-linux-${{ matrix.arch }}
path: untrunc-linux-${{ matrix.arch }}

build-macos:
name: macOS (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
needs: get-ffmpeg-version
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
arch: x86_64
- os: macos-14
arch: arm64

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Cache compiled FFmpeg
id: cache-ffmpeg
uses: actions/cache@v4
with:
path: ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}
key: ffmpeg-built-macos-${{ matrix.arch }}-${{ needs.get-ffmpeg-version.outputs.version }}

- name: Install build tools
run: brew install nasm wget

- name: Build FFmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
wget -q -O /tmp/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz \
https://www.ffmpeg.org/releases/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz
tar xf /tmp/ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}.tar.xz
mv ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}/VERSION \
ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}/VERSION.bak
cd ffmpeg-${{ needs.get-ffmpeg-version.outputs.version }}
./configure --disable-doc --disable-programs \
--disable-everything --enable-decoders --disable-vdpau --enable-demuxers --enable-protocol=file \
--disable-avdevice --disable-swresample --disable-swscale --disable-avfilter \
--disable-xlib --disable-vaapi --disable-zlib --disable-bzlib --disable-lzma \
--disable-audiotoolbox --disable-videotoolbox
make -j$(sysctl -n hw.logicalcpu)

- name: Build untrunc
run: |
make FF_VER=${{ needs.get-ffmpeg-version.outputs.version }} IS_RELEASE=1
mv untrunc untrunc-macos-${{ matrix.arch }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: untrunc-macos-${{ matrix.arch }}
path: untrunc-macos-${{ matrix.arch }}

release:
name: Create Release
runs-on: ubuntu-latest
needs: [get-ffmpeg-version, build-linux, build-macos]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/*
body: |
## Untrunc Release

Automated builds for **Linux** and **macOS**, compiled with **FFmpeg ${{ needs.get-ffmpeg-version.outputs.version }}** (bundled — no ffmpeg installation needed).

### Which file to choose?

| Platform | CPU | File |
|---|---|---|
| Linux 64-bit (Intel/AMD) | x86_64 | `untrunc-linux-amd64` |
| Linux 64-bit (ARM, e.g. RPi 4/5) | aarch64 | `untrunc-linux-arm64` |
| Linux 32-bit (ARM, e.g. RPi 2/3) | armv7 | `untrunc-linux-armv7` |
| Linux 32-bit (Intel/AMD) | i386 | `untrunc-linux-i386` |
| macOS (Intel) | x86_64 | `untrunc-macos-x86_64` |
| macOS (Apple Silicon M1/M2/M3) | arm64 | `untrunc-macos-arm64` |

Loading