build custom libs #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| # push: | |
| # branches: [master] | |
| workflow_dispatch: | |
| inputs: | |
| os: | |
| description: 'macos version' | |
| required: false | |
| type: choice | |
| default: 'macos-15' | |
| options: | |
| - macos-13 | |
| - macos-14 | |
| - macos-15 | |
| - macos-26 | |
| platform: | |
| description: 'choose a platform for compile' | |
| required: false | |
| type: choice | |
| default: 'all' | |
| options: | |
| - apple | |
| - android | |
| - ios | |
| - tvos | |
| - macos | |
| - all | |
| libraries: | |
| description: 'input libraries for compile' | |
| required: true | |
| default: 'xml2' | |
| dryrun: | |
| description: 'just run workflow,but not deploy' | |
| required: false | |
| type: choice | |
| default: 'false' | |
| options: | |
| - true | |
| - false | |
| verbose: | |
| description: 'print detail logs' | |
| required: false | |
| type: choice | |
| default: 'false' | |
| options: | |
| - true | |
| - false | |
| pull_request: | |
| branches: [master] | |
| name: build custom libs | |
| jobs: | |
| build: | |
| name: compile all libs for ${{ inputs.platform }} then deploy | |
| runs-on: ${{ inputs.os }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - uses: nttld/setup-ndk@v1 | |
| id: setup-ndk | |
| with: | |
| ndk-version: r27c | |
| add-to-path: true | |
| local-cache: false | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: One Step | |
| run: | | |
| Platform=${{ inputs.platform }} | |
| DryRun=${{ inputs.dryrun }} | |
| Verbose=${{ inputs.verbose }} | |
| compile_lib() { | |
| local lib_name=$1 | |
| local platform=$Platform | |
| if [[ "$lib_name" == "fontconfig" ]]; then | |
| if [[ "$platform" == "all" ]]; then | |
| echo "force platform to android for fontconfig" | |
| platform='android' | |
| elif [[ "$platform" != "android" ]]; then | |
| echo "Skip fontconfig for $platform" | |
| return | |
| fi | |
| fi | |
| if [[ "$lib_name" == "webp" ]]; then | |
| if [[ "$platform" == "android" ]]; then | |
| echo "Skip webp for android" | |
| return | |
| elif [[ "$platform" == "all" ]]; then | |
| echo "Skip webp for android" | |
| platform='apple' | |
| fi | |
| fi | |
| echo "------compile $platform $lib_name------------------------------------" | |
| rm -rf build || git reset --hard || git pull origin | |
| .github/workflows/install-dependencies.sh $lib_name $platform # 补全依赖安装步骤 | |
| .github/workflows/onestep.sh $lib_name $platform $DryRun $Verbose | |
| } | |
| # 将逗号分隔转为循环处理 | |
| IFS=',' read -ra ADDR <<< "${{ inputs.libraries }}" | |
| for lib in "${ADDR[@]}"; do | |
| compile_lib "$lib" | |
| done | |
| env: | |
| ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} |