Skip to content

Build libwebp main

Build libwebp main #33

Workflow file for this run

name: Build libwebp
run-name: Build libwebp ${{ inputs.webp_branch || 'main' }}
on:
schedule:
# Run weekly on Monday at 10:00 AM UTC (after Skia builds)
- cron: '0 10 * * 1'
workflow_dispatch:
inputs:
webp_branch:
description: 'libwebp branch/tag to build'
required: false
type: string
default: 'main'
platforms:
description: 'Platforms to build (comma-separated, or "all")'
required: false
type: string
default: 'all'
skip_release:
description: 'Skip creating release'
required: false
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build-webp:
strategy:
fail-fast: false
matrix:
include:
# macOS builds
- os: macos-latest
platform: mac
arch: "universal"
- os: macos-latest
platform: mac
arch: "arm64"
- os: macos-latest
platform: mac
arch: "x86_64"
# iOS builds
- os: macos-latest
platform: ios
arch: "arm64"
target: "device"
- os: macos-latest
platform: ios
arch: "arm64,x86_64"
target: "simulator"
# visionOS builds
- os: macos-latest
platform: visionos
arch: "arm64"
target: "device"
- os: macos-latest
platform: visionos
arch: "arm64"
target: "simulator"
# Windows builds
- os: windows-latest
platform: win
arch: x64
crt: static
- os: windows-latest
platform: win
arch: x64
crt: dynamic
# Linux builds
- os: ubuntu-latest
platform: linux
arch: x64
# Android builds (arm64 only for now)
- os: ubuntu-latest
platform: android
arch: arm64
# - os: ubuntu-latest
# platform: android
# arch: arm
# - os: ubuntu-latest
# platform: android
# arch: x64
# WASM builds
- os: ubuntu-latest
platform: wasm
arch: wasm32
runs-on: ${{ matrix.os }}
steps:
- name: Check if platform should build
id: check
shell: bash
run: |
PLATFORMS="${{ inputs.platforms || 'all' }}"
if [[ "$PLATFORMS" == "all" ]] || [[ "$PLATFORMS" == *"${{ matrix.platform }}"* ]]; then
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "should_build=false" >> $GITHUB_OUTPUT
echo "Skipping ${{ matrix.platform }} (not in platforms: $PLATFORMS)"
fi
- name: Checkout repository
if: steps.check.outputs.should_build == 'true'
uses: actions/checkout@v4
- name: Free disk space (Linux)
if: steps.check.outputs.should_build == 'true' && runner.os == 'Linux'
run: |
# Don't remove Android SDK if building for Android
if [[ "${{ matrix.platform }}" == "android" ]]; then
sudo rm -rf /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
else
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
fi
sudo docker image prune --all --force
- name: Set up Android NDK
if: steps.check.outputs.should_build == 'true' && matrix.platform == 'android'
uses: android-actions/setup-android@v3
with:
packages: 'ndk;26.1.10909125'
- name: Set Android NDK environment
if: steps.check.outputs.should_build == 'true' && matrix.platform == 'android'
run: |
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV
echo "ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV
- name: Set up Ninja
if: steps.check.outputs.should_build == 'true'
uses: seanmiddleditch/gha-setup-ninja@v5
- name: Set up Python
if: steps.check.outputs.should_build == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Set up Emscripten
if: steps.check.outputs.should_build == 'true' && matrix.platform == 'wasm'
uses: mymindstorm/setup-emsdk@v14
with:
version: 'latest'
# Windows uses Visual Studio generator, no need for LLVM
- name: Cache libwebp source
if: steps.check.outputs.should_build == 'true'
uses: actions/cache@v4
with:
path: build/src/libwebp
key: libwebp-${{ inputs.webp_branch || 'main' }}-${{ hashFiles('build-webp.py') }}
restore-keys: |
libwebp-${{ inputs.webp_branch || 'main' }}-
- name: Build libwebp
if: steps.check.outputs.should_build == 'true'
shell: bash
run: |
ARGS="${{ matrix.platform }} -config Release"
ARGS="$ARGS -branch ${{ inputs.webp_branch || 'main' }}"
if [[ -n "${{ matrix.arch }}" ]]; then
ARGS="$ARGS -archs ${{ matrix.arch }}"
fi
if [[ -n "${{ matrix.target }}" ]]; then
ARGS="$ARGS -target ${{ matrix.target }}"
fi
if [[ -n "${{ matrix.crt }}" ]]; then
ARGS="$ARGS -crt ${{ matrix.crt }}"
fi
if [[ "${{ matrix.platform }}" == "android" ]]; then
ARGS="$ARGS -ndk $ANDROID_NDK_HOME"
fi
ARGS="$ARGS --shallow"
echo "Running: python3 build-webp.py $ARGS"
python3 build-webp.py $ARGS
- name: Set archive name
if: steps.check.outputs.should_build == 'true'
id: archive
shell: bash
run: |
PLATFORM="${{ matrix.platform }}"
ARCH="${{ matrix.arch }}"
TARGET="${{ matrix.target }}"
CRT="${{ matrix.crt }}"
NAME="webp-${PLATFORM}"
if [[ -n "$TARGET" ]]; then
NAME="${NAME}-${TARGET}"
fi
NAME="${NAME}-${ARCH//,/-}"
if [[ -n "$CRT" ]]; then
NAME="${NAME}-${CRT}"
fi
echo "name=${NAME}" >> $GITHUB_OUTPUT
- name: Package binaries
if: steps.check.outputs.should_build == 'true'
shell: bash
run: |
mkdir -p artifacts
# Copy libraries
if [[ "${{ matrix.platform }}" == "win" ]]; then
CRT_SUFFIX=""
if [[ "${{ matrix.crt }}" == "dynamic" ]]; then
CRT_SUFFIX="-md"
fi
cp -r build/webp-win${CRT_SUFFIX}/lib artifacts/ 2>/dev/null || true
else
cp -r build/webp-${{ matrix.platform }}/lib artifacts/ 2>/dev/null || true
fi
# Copy headers (only once per platform group)
if [[ "${{ matrix.arch }}" == "universal" ]] || [[ "${{ matrix.arch }}" == "arm64" && -z "${{ matrix.target }}" ]]; then
cp -r build/include artifacts/ 2>/dev/null || true
fi
- name: Upload artifact
if: steps.check.outputs.should_build == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.archive.outputs.name }}
path: artifacts/
retention-days: 30
create-release:
needs: build-webp
if: ${{ !inputs.skip_release }}
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create combined archive
run: |
mkdir -p release
# Combine all artifacts
for dir in artifacts/*/; do
if [ -d "$dir" ]; then
cp -r "$dir"/* release/ 2>/dev/null || true
fi
done
# Create tarball
BRANCH="${{ inputs.webp_branch || 'main' }}"
DATE=$(date +%Y%m%d)
tar -czvf "webp-${BRANCH}-${DATE}.tar.gz" -C release .
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: webp-${{ inputs.webp_branch || 'main' }}-${{ github.run_number }}
name: libwebp ${{ inputs.webp_branch || 'main' }} Build ${{ github.run_number }}
body: |
Automated libwebp build from branch `${{ inputs.webp_branch || 'main' }}`
## Platforms
- macOS (universal, arm64, x86_64)
- iOS (device arm64, simulator arm64+x86_64)
- visionOS (device arm64, simulator arm64)
- Windows (x64, static and dynamic CRT)
- Linux (x64)
- Android (arm64, arm, x64)
- WASM (wasm32)
## Libraries
- libwebp (encoder/decoder)
- libwebpdecoder (decoder only)
- libwebpdemux (demuxing)
- libwebpmux (muxing)
- libsharpyuv (color space conversion)
files: |
*.tar.gz
draft: false
prerelease: false