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
127 changes: 127 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Build PDFium & Deploy to falcon-pdfium-binaries

on:
workflow_dispatch:
inputs:
ref:
description: 'Git ref to build (default: android-ios-build)'
required: false
default: android-ios-build

permissions:
contents: read

jobs:
build-android:
name: Build Android (${{ matrix.target }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- { target: arm64-v8a, output_dir: android-arm64 }
- { target: armeabi-v7a, output_dir: android-arm }
- { target: x86, output_dir: android-x86 }
- { target: x86_64, output_dir: android-x64 }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Install depot_tools
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 base deps
run: |
sudo apt-get update
sudo apt-get install -y cmake clang lld curl g++ pkg-config tar

- name: Build target
run: scripts/embedpdf-runtime/build-target.sh "${{ matrix.target }}"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pdfium-android-${{ matrix.target }}
path: out/embedpdf-runtime/${{ matrix.output_dir }}/libpdfium.so

build-ios:
name: Build iOS (${{ matrix.target }})
runs-on: macos-15
strategy:
fail-fast: false
matrix:
include:
- { target: ios-arm64, output_dir: ios-arm64 }
- { target: ios-simulator-arm64, output_dir: ios-simulator-arm64 }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Install depot_tools
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "$RUNNER_TEMP/depot_tools"
echo "$RUNNER_TEMP/depot_tools" >> "$GITHUB_PATH"

- name: Build target
run: scripts/embedpdf-runtime/build-target.sh "${{ matrix.target }}"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pdfium-${{ matrix.target }}
path: out/embedpdf-runtime/${{ matrix.output_dir }}/libpdfium.a

deploy:
name: Deploy binaries to falcon-pdfium-binaries
needs: [build-android, build-ios]
runs-on: macos-15
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Checkout falcon-pdfium-binaries
uses: actions/checkout@v4
with:
repository: avrapps/falcon-pdfium-binaries
token: ${{ secrets.PDFIUM_BINARIES_PAT }}
path: falcon-pdfium-binaries

- name: Copy Android binaries
run: |
cp artifacts/pdfium-android-arm64-v8a/libpdfium.so falcon-pdfium-binaries/binaries/android/arm64-v8a/libpdfium.so
cp artifacts/pdfium-android-armeabi-v7a/libpdfium.so falcon-pdfium-binaries/binaries/android/armeabi-v7a/libpdfium.so
cp artifacts/pdfium-android-x86/libpdfium.so falcon-pdfium-binaries/binaries/android/x86/libpdfium.so
cp artifacts/pdfium-android-x86_64/libpdfium.so falcon-pdfium-binaries/binaries/android/x86_64/libpdfium.so

- name: Build iOS xcframework
run: |
mkdir -p staging/ios-arm64 staging/ios-simulator-arm64
cp artifacts/pdfium-ios-arm64/libpdfium.a staging/ios-arm64/libpdfium.a
cp artifacts/pdfium-ios-simulator-arm64/libpdfium.a staging/ios-simulator-arm64/libpdfium.a

# Remove existing xcframework and rebuild
rm -rf falcon-pdfium-binaries/binaries/ios-framework/pdfium.xcframework
xcodebuild -create-xcframework \
-library staging/ios-arm64/libpdfium.a \
-library staging/ios-simulator-arm64/libpdfium.a \
-output falcon-pdfium-binaries/binaries/ios-framework/pdfium.xcframework

- name: Commit and push
working-directory: falcon-pdfium-binaries
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
else
SHORT_SHA=$(cd .. && cd artifacts && echo "${{ github.sha }}" | cut -c1-7)
git commit -m "chore: update pdfium binaries from avrapps/pdfium@${SHORT_SHA}"
git push
fi
74 changes: 70 additions & 4 deletions .github/workflows/release-libpdfium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
default: false

permissions:
contents: read
contents: write

jobs:
source-tests:
Expand Down Expand Up @@ -57,15 +57,27 @@ jobs:
fail-fast: false
matrix:
include:
# Linux & Wasm
- { target: linux-x64, runner: ubuntu-24.04 }
- { target: linux-arm64, runner: ubuntu-24.04 }
- { target: linuxmusl-x64, runner: ubuntu-24.04 }
- { target: linuxmusl-arm64, runner: ubuntu-24.04 }
- { target: wasm32, runner: ubuntu-24.04 }
# Darwin (macOS)
- { target: darwin-arm64, runner: macos-15 }
- { target: darwin-x64, runner: macos-15 }
# Windows
- { target: win32-x64, runner: windows-2022 }
- { target: win32-arm64, runner: windows-2022 }
# Android
- { target: arm64-v8a, runner: ubuntu-24.04 }
- { target: armeabi-v7a, runner: ubuntu-24.04 }
- { target: x86, runner: ubuntu-24.04 }
- { target: x86_64, runner: ubuntu-24.04 }
# iOS
- { target: ios-arm64, runner: macos-15 }
- { target: ios-simulator-arm64, runner: macos-15 }
- { target: ios-simulator-x64, runner: macos-15 }
env:
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
EMSDK_VERSION: 3.1.72
Expand Down Expand Up @@ -132,7 +144,7 @@ jobs:
- name: Select Xcode
if: runner.os == 'macOS'
shell: bash
run: sudo xcode-select -s "/Applications/Xcode_26.0.app"
run: sudo xcode-select -s "/Applications/Xcode_16.1.app"
- name: Install Windows deps
if: runner.os == 'Windows'
shell: pwsh
Expand Down Expand Up @@ -161,18 +173,72 @@ jobs:
name: libembedpdf-pdf-runtime-${{ matrix.target }}
path: out/embedpdf-runtime-artifacts/*.tar.gz

ios-universal:
name: Build ios-arm64_x86_64-simulator
needs: build
runs-on: macos-15
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref_name }}
- uses: actions/download-artifact@v6
with:
name: libembedpdf-pdf-runtime-ios-simulator-arm64
path: artifacts/ios-simulator-arm64
- uses: actions/download-artifact@v6
with:
name: libembedpdf-pdf-runtime-ios-simulator-x64
path: artifacts/ios-simulator-x64
- name: Combine iOS simulator libraries
shell: bash
run: |
mkdir -p out/ios-universal/lib

# Unpack
mkdir -p staging/arm64 staging/x64
tar -xzf artifacts/ios-simulator-arm64/*.tar.gz -C staging/arm64
tar -xzf artifacts/ios-simulator-x64/*.tar.gz -C staging/x64

# Combine with lipo
lipo -create staging/arm64/lib/libpdfium.a staging/x64/lib/libpdfium.a -output out/ios-universal/lib/libpdfium.a

# Copy headers and other files from one of them
mkdir -p out/ios-universal/include out/ios-universal/LICENSES
cp -R staging/arm64/include/. out/ios-universal/include/
cp -R staging/arm64/LICENSES/. out/ios-universal/LICENSES/
cp staging/arm64/args.gn out/ios-universal/args.gn

# Write metadata
cat > out/ios-universal/BUILD-METADATA.json <<EOF
{
"name": "embedpdf-pdf-runtime",
"target": "ios-arm64_x86_64-simulator",
"sha": "$(git rev-parse HEAD)",
"createdAt": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
}
EOF

# Package
mkdir -p out/embedpdf-runtime-artifacts
short_sha=$(git rev-parse --short HEAD)
tar -czf "out/embedpdf-runtime-artifacts/libembedpdf-pdf-runtime-ios-arm64_x86_64-simulator-$short_sha.tar.gz" -C out/ios-universal .
- uses: actions/upload-artifact@v6
with:
name: libembedpdf-pdf-runtime-ios-arm64_x86_64-simulator
path: out/embedpdf-runtime-artifacts/*.tar.gz

release:
name: Publish release
runs-on: ubuntu-24.04
needs: build
needs: [build, ios-universal]
if: github.event_name == 'workflow_dispatch' && inputs.release == true
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref_name }}
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v6
with:
path: artifacts
- name: Flatten artifacts
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/sync-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Sync upstream pdfium

on:
schedule:
- cron: '0 6 * * 1' # Every Monday at 6am UTC
workflow_dispatch: # Manual trigger from Actions tab

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: android-ios-build
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Add upstream remote
run: git remote add upstream https://github.com/embedpdf/pdfium.git

- name: Fetch upstream
run: git fetch upstream

- name: Check for new commits
id: check
run: |
UPSTREAM_HEAD=$(git rev-parse upstream/embedpdf/main)
if git merge-base --is-ancestor "$UPSTREAM_HEAD" HEAD; then
echo "up_to_date=true" >> $GITHUB_OUTPUT
else
echo "up_to_date=false" >> $GITHUB_OUTPUT
fi

- name: Rebase on upstream
if: steps.check.outputs.up_to_date == 'false'
run: |
git rebase upstream/embedpdf/main || {
echo "::error::Rebase failed due to conflicts. Manual resolution required."
git rebase --abort
exit 1
}

- name: Push rebased changes
if: steps.check.outputs.up_to_date == 'false'
run: git push origin android-ios-build --force-with-lease
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@
*.vcxproj
*.xcodeproj
*~
.idea

Loading