Build wheels #29
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
| name: Build wheels | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| archs: | |
| description: "Architectures (comma-separated, e.g. android,iOS)" | |
| required: false | |
| default: "android,iOS" | |
| packages: | |
| description: "Packages (comma-separated, e.g. pillow:11.1.0,pydantic-core:2.33.2)" | |
| required: false | |
| default: "pydantic-core:2.33.2" | |
| build_number: | |
| description: "Build number" | |
| required: false | |
| default: "1" | |
| env: | |
| PYTHON_VERSION: "3.12.12" | |
| PYTHON_SHORT_VERSION: "3.12" | |
| MOBILE_FORGE_CACHE_DOWNLOADS_OFF: "1" | |
| NDK_VERSION: r27d | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - id: set-matrix | |
| shell: bash | |
| run: | | |
| ARCHS="${{ inputs.archs || 'android,iOS' }}" | |
| PACKAGES="${{ inputs.packages || 'pydantic-core:2.33.2' }}" | |
| BUILD_NUMBER="${{ inputs.build_number || '1' }}" | |
| matrix='{"include":[' | |
| first=true | |
| for arch in $(echo "$ARCHS" | tr ',' ' '); do | |
| for pkg in $(echo "$PACKAGES" | tr ',' ' '); do | |
| pkg_name="${pkg%%:*}" | |
| if [ "$first" = true ]; then first=false; else matrix+=','; fi | |
| if [[ "$arch" == "android" ]]; then | |
| runner="ubuntu-latest" | |
| platform="android" | |
| else | |
| runner="macos-latest" | |
| platform="ios" | |
| fi | |
| matrix+="{\"job_name\":\"${platform}: ${pkg_name}\",\"artifact_name\":\"${platform}-${pkg_name}\",\"runner\":\"$runner\",\"platform\":\"$platform\",\"forge_arch\":\"$arch\",\"forge_packages\":\"$pkg\",\"build_number\":\"$BUILD_NUMBER\"}" | |
| done | |
| done | |
| matrix+=']}' | |
| echo "matrix=$matrix" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: setup | |
| name: ${{ matrix.job_name }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.setup.outputs.matrix) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_SHORT_VERSION }} | |
| - name: Build and publish wheels | |
| shell: bash | |
| env: | |
| GEMFURY_TOKEN: ${{ secrets.GEMFURY_TOKEN }} | |
| APPVEYOR_PULL_REQUEST_NUMBER: "" | |
| FORGE_ARCH: ${{ matrix.forge_arch }} | |
| FORGE_PACKAGES: ${{ matrix.forge_packages }} | |
| BUILD_NUMBER: ${{ matrix.build_number }} | |
| PLATFORM: ${{ matrix.platform }} | |
| run: | | |
| set -euxo pipefail | |
| . .ci/common.sh | |
| export MOBILE_FORGE_ANDROID_SUPPORT_PATH="" | |
| export MOBILE_FORGE_IOS_SUPPORT_PATH="" | |
| if [[ "$PLATFORM" == "android" ]]; then | |
| sudo apt-get update | |
| sudo apt-get install -y sqlite3 | |
| python_android_dir="$HOME/projects/python-build/android" | |
| curl -#OL "https://github.com/flet-dev/python-build/releases/download/v${PYTHON_SHORT_VERSION}/python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" | |
| mkdir -p "$python_android_dir" | |
| tar -xzf "python-android-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" -C "$python_android_dir" | |
| . .ci/install_ndk.sh | |
| curl https://sh.rustup.rs -sSf | sh -s -- -y | |
| . "$HOME/.cargo/env" | |
| export PATH="$PATH:$HOME/.cargo/bin" | |
| rustup target add aarch64-linux-android | |
| rustup target add arm-linux-androideabi | |
| rustup target add x86_64-linux-android | |
| rustup target add i686-linux-android | |
| export MOBILE_FORGE_ANDROID_SUPPORT_PATH="$python_android_dir" | |
| else | |
| python_ios_dir="$HOME/projects/python-build/darwin/Python-Apple-support" | |
| curl -#OL "https://github.com/flet-dev/python-build/releases/download/v${PYTHON_SHORT_VERSION}/python-ios-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" | |
| mkdir -p "$python_ios_dir" | |
| tar -xzf "python-ios-mobile-forge-${PYTHON_SHORT_VERSION}.tar.gz" -C "$python_ios_dir" | |
| curl https://sh.rustup.rs -sSf | sh -s -- -y | |
| . "$HOME/.cargo/env" | |
| export PATH="$PATH:$HOME/.cargo/bin" | |
| rustup target add aarch64-apple-ios | |
| rustup target add aarch64-apple-ios-sim | |
| rustup target add x86_64-apple-ios | |
| export MOBILE_FORGE_IOS_SUPPORT_PATH="$python_ios_dir" | |
| fi | |
| source ./setup.sh "$PYTHON_VERSION" | |
| export PATH="$PATH:$HOME/.cargo/bin" | |
| IFS=' ' read -r -a packages <<< "$FORGE_PACKAGES" | |
| for package in "${packages[@]}"; do | |
| forge "$FORGE_ARCH" "$package:$BUILD_NUMBER" | |
| done | |
| rm -f dist/bzip2-* dist/xz-* dist/openssl-* dist/libffi-* | |
| if compgen -G "dist/*.whl" > /dev/null; then | |
| publish_to_pypi dist/*.whl | |
| fi | |
| - name: Upload logs on success | |
| if: ${{ success() && hashFiles('logs/*.log') != '' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: logs-${{ matrix.artifact_name }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| path: logs/*.log | |
| - name: Upload errors on failure | |
| if: ${{ failure() && hashFiles('errors/*.log') != '' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: errors-${{ matrix.artifact_name }}-${{ github.run_id }}-${{ github.run_attempt }} | |
| path: errors/*.log |