Skip to content

Release EmbedPDF PDF Runtime Libraries #8

Release EmbedPDF PDF Runtime Libraries

Release EmbedPDF PDF Runtime Libraries #8

name: Release EmbedPDF PDF Runtime Libraries
on:
workflow_dispatch:
inputs:
ref:
description: Git ref to build
required: false
default: embedpdf/main
release:
description: Publish GitHub release
type: boolean
required: false
default: false
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.group }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- group: linux-x64-wasm
runner: ubuntu-24.04
targets: linux-x64 linuxmusl-x64 wasm32
target_os: linux emscripten
- group: linux-arm64
runner: ubuntu-24.04
targets: linux-arm64 linuxmusl-arm64
target_os: linux
- group: darwin
runner: macos-15
targets: darwin-arm64 darwin-x64
target_os: mac
- group: win32
runner: windows-2022
targets: win32-x64 win32-arm64
target_os: win
env:
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
EMSDK_VERSION: 3.1.72
MUSL_URLS: ${{ secrets.MUSL_URL || 'https://more.musl.cc https://musl.cc' }}
PDF_RUNTIME_TARGET_OS_LIST: ${{ matrix.target_os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref_name }}
- name: Install depot_tools
shell: bash
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "$RUNNER_TEMP/depot_tools"
echo "$RUNNER_TEMP/depot_tools" >> "$GITHUB_PATH"
- name: Install Linux deps
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y cmake curl g++ pkg-config tar
download_musl_toolchain() {
local triple="$1"
local archive="$triple-cross.tgz"
for base_url in $MUSL_URLS; do
local url="$base_url/$archive"
if [[ "$base_url" == *"more.musl.cc"* ]]; then
url="$base_url/$triple/$archive"
fi
echo "Downloading $url"
if curl --fail --location --retry 5 --retry-all-errors --connect-timeout 20 --max-time 300 -o "$archive" "$url"; then
tar xzf "$archive"
echo "$PWD/$triple-cross/bin" >> "$GITHUB_PATH"
return
fi
done
echo "Failed to download musl toolchain for $triple" >&2
exit 1
}
if [[ " ${{ matrix.targets }} " == *" linux-arm64 "* ]]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi
if [[ " ${{ matrix.targets }} " == *" linuxmusl-x64 "* ]]; then
download_musl_toolchain x86_64-linux-musl
fi
if [[ " ${{ matrix.targets }} " == *" linuxmusl-arm64 "* ]]; then
download_musl_toolchain aarch64-linux-musl
fi
if [[ " ${{ matrix.targets }} " == *" wasm32 "* ]]; then
mkdir -p third_party
if [[ -d third_party/emsdk ]]; then
git -C third_party/emsdk pull
else
git clone https://github.com/emscripten-core/emsdk.git third_party/emsdk
fi
third_party/emsdk/emsdk install "$EMSDK_VERSION"
third_party/emsdk/emsdk activate "$EMSDK_VERSION"
echo "$PWD/third_party/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
echo "$PWD/third_party/emsdk/upstream/bin" >> "$GITHUB_PATH"
fi
- name: Select Xcode
if: runner.os == 'macOS'
shell: bash
run: sudo xcode-select -s "/Applications/Xcode_26.0.app"
- name: Build and package targets
shell: bash
run: |
for target in ${{ matrix.targets }}; do
scripts/embedpdf-runtime/build-target.sh "$target"
scripts/embedpdf-runtime/package-target.sh "$target"
done
- uses: actions/upload-artifact@v6
with:
name: libembedpdf-pdf-runtime-${{ matrix.group }}
path: out/embedpdf-runtime-artifacts/*.tar.gz
release:
name: Publish release
runs-on: ubuntu-24.04
needs: build
if: inputs.release == true
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref_name }}
- uses: actions/download-artifact@v7
with:
path: artifacts
- name: Flatten artifacts
shell: bash
run: |
mkdir -p out/embedpdf-runtime-artifacts
find artifacts -name '*.tar.gz' -exec cp {} out/embedpdf-runtime-artifacts/ \;
- name: Write manifest
shell: bash
run: |
tag="runtime-$(git rev-parse HEAD)"
export PDF_RUNTIME_ARTIFACT_DIR="$PWD/out/embedpdf-runtime-artifacts"
export PDF_RUNTIME_RELEASE_BASE_URL="https://github.com/${{ github.repository }}/releases/download/$tag"
scripts/embedpdf-runtime/write-manifest.sh "$PDF_RUNTIME_ARTIFACT_DIR/pdf-runtime-build.generated.json"
- uses: ncipollo/release-action@v1
with:
tag: runtime-${{ github.sha }}
name: EmbedPDF PDF Runtime ${{ github.sha }}
artifacts: out/embedpdf-runtime-artifacts/*
allowUpdates: true