Skip to content

Commit

Permalink
ci: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed Oct 26, 2024
1 parent 1d32b7f commit f297c2e
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 190 deletions.
176 changes: 0 additions & 176 deletions .github/actions/build-pdfium.yml

This file was deleted.

File renamed without changes.
163 changes: 163 additions & 0 deletions .github/actions/setup-pdfium/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Build PDFium

inputs:
# branch:
# description: PDFium branch
# type: string
# required: false
# default: main
version:
description: PDFium version
required: false
default: '6666'
target_os:
description: Target OS (android|ios|linux|mac|wasm|win)
required: true
target_cpu:
description: Target CPU (arm|arm64|x64|x86|wasm)
required: true
target_environment:
description: Target environment (device|catalyst|simulator|musl)
required: false
default: ''
static_lib:
description: Static Library
required: false
default: 'true'
debug:
description: Debug
required: false
default: 'false'
enable_v8:
description: Enable V8
required: false
default: 'false'
emsdk_version:
description: Emscripten SDK
required: false
default: 3.1.69
outputs:
artifact:
description: 'The name of the artifact'
value: ${{ jobs.build.outputs.artifact }}

runs:
using: composite
steps:
- name: Initialize
id: init
shell: bash
run: |
ARTIFACT="pdfium"
[ "${{ inputs.enable_v8 }}" == "true" ] && ARTIFACT="$ARTIFACT-v8"
ARTIFACT="$ARTIFACT-${{ inputs.target_os }}"
[ "${{ inputs.target_environment }}" != "" ] && ARTIFACT="$ARTIFACT-${{ inputs.target_environment }}"
[ "${{ inputs.target_os }}" != "${{ inputs.target_cpu }}" ] && ARTIFACT="$ARTIFACT-${{ inputs.target_cpu }}"
[ "${{ inputs.debug }}" == "true" ] && ARTIFACT="$ARTIFACT-debug"
echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT
- name: Checkout this repo
uses: actions/checkout@v4

- name: Install Linux dependencies
if: ${{ inputs.target_os == 'linux' }}
run: |
PKGS=""
if [ "${{ inputs.target_environment }}" == "musl" ]; then
case "${{ inputs.target_cpu }}" in
x86)
PKGS="g++-12 g++-12-multilib"
;;
x64)
PKGS="g++-12"
;;
arm)
PKGS="g++-12"
;;
arm64)
PKGS="g++-12"
;;
esac
else
case "${{ inputs.target_cpu }}" in
arm)
PKGS="libc6-i386 gcc-12-multilib g++-12-arm-linux-gnueabihf gcc-12-arm-linux-gnueabihf"
;;
arm64)
PKGS="libc6-i386 gcc-12-multilib g++-12-aarch64-linux-gnu gcc-12-aarch64-linux-gnu"
;;
x86)
PKGS="g++-12-multilib"
;;
x64)
PKGS="g++-12"
;;
esac
fi
sudo apt-get update
sudo apt-get install -y cmake pkg-config $PKGS
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
- name: Install Just
uses: extractions/setup-just@v2

- name: Install EMSDK
if: ${{ inputs.target_os == 'wasm' }}
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ inputs.emsdk_version }}

- name: Set environment variables
shell: bash
run: |
cat >> .env <<END
TARGET_OS = "${{ inputs.target_os }}"
TARGET_CPU = "${{ inputs.target_cpu }}"
STATIC_LIB = ${{ inputs.static_lib }}
DEBUG = ${{ inputs.debug }}
ENABLE_V8 = ${{ inputs.enable_v8 }}
PDFIUM_VERSION=${{ inputs.version }}
END
[ "${{ inputs.target_os }}" == "ios" ] && [ "${{ inputs.target_environment }}" != "" ] && echo "target_environment = \"${{ inputs.target_environment }}\"" >> .env
echo "${PWD}/depot_tools" >> $GITHUB_PATH
- name: Build
shell: bash
run: |
just -v build pack
- name: Build & Install WASM
if: ${{ inputs.target_os == 'wasm' }}
shell: bash
run: |
just -v build-wasm
just -v install-wasm
- name: Configure
run: |
target="${{ inputs.target_os }}"
[ "${{ inputs.target_os }}" != "${{ inputs.target_cpu }}" ] && target="$target-${{ inputs.target_cpu }}"
cat <<END >> $GITHUB_STEP_SUMMARY
## ${target}'s args.gn
\`\`\`gn
$(cat pdfium/out/$target/args.gn)
\`\`\`
END
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.init.outputs.artifact }}
path: dist/
26 changes: 15 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ on:
jobs:
build:
name: Build - ${{ github.event.inputs.target_os }} ${{ github.event.inputs.target_cpu }} ${{ github.event.inputs.target_environment }}
uses: ./.github/actions/build-pdfium.yml
with:
# branch: ${{ github.event.inputs.branch }}
version: ${{ github.event.inputs.version }}
target_os: ${{ github.event.inputs.target_os }}
target_cpu: ${{ github.event.inputs.target_cpu }}
target_environment: ${{ github.event.inputs.target_environment }}
enable_v8: ${{ github.event.inputs.enable_v8 == 'true' }}
emsdk_version: ${{ github.event.inputs.emsdk_version }}
static_lib: ${{ github.event.inputs.static_lib == 'true' }}
debug: ${{ github.event.inputs.debug == 'true' }}
outputs:
artifact: ${{ steps.init.outputs.artifact }}
runs-on: ${{ (github.event.inputs.target_os == 'ios' || github.event.inputs.target_os == 'mac') && 'macos-latest' || github.event.inputs.target_os == 'win' && 'windows-2022' || 'ubuntu-22.04' }}
steps:
- uses: ./.github/actions/build-pdfium.yml
with:
# branch: ${{ github.event.inputs.branch }}
version: ${{ github.event.inputs.version }}
target_os: ${{ github.event.inputs.target_os }}
target_cpu: ${{ github.event.inputs.target_cpu }}
target_environment: ${{ github.event.inputs.target_environment }}
enable_v8: ${{ github.event.inputs.enable_v8 == 'true' }}
emsdk_version: ${{ github.event.inputs.emsdk_version }}
static_lib: ${{ github.event.inputs.static_lib == 'true' }}
debug: ${{ github.event.inputs.debug == 'true' }}
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
- name: Setup Node.js
uses: ./.github/actions/setup-node

- name: Create Release Pull Request
id: changesets
Expand All @@ -38,9 +39,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
- name: Setup Node.js
uses: ./.github/actions/setup-node

- uses: ./.github/actions/build-pdfium.yml
- name: Setup PDFium
uses: ./.github/actions/build-pdfium.yml
with:
target_os: wasm
target_cpu: wasm
Expand Down

0 comments on commit f297c2e

Please sign in to comment.