feat: grpc builder追加 #2
Workflow file for this run
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 gRPC PHP Extension | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| grpc_version: | |
| description: 'gRPC version to build' | |
| required: true | |
| default: '1.68.0' | |
| env: | |
| GRPC_VERSION: ${{ github.event.inputs.grpc_version || '1.68.0' }} | |
| jobs: | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php_version: ['8.0', '8.1', '8.2', '8.3', '8.4'] | |
| arch: ['x86_64', 'aarch64'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| if: matrix.arch == 'aarch64' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Build gRPC extension | |
| run: | | |
| docker run --rm \ | |
| --platform linux/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} \ | |
| -v $PWD:/output \ | |
| php:${{ matrix.php_version }}-cli \ | |
| bash -c " | |
| apt-get update && apt-get install -y git build-essential autoconf zlib1g-dev | |
| # Install gRPC | |
| pecl install grpc-${GRPC_VERSION} | |
| # Copy the built extension | |
| PHP_EXT_DIR=\$(php-config --extension-dir) | |
| cp \$PHP_EXT_DIR/grpc.so /output/grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.so | |
| # Create metadata | |
| echo \"PHP Version: ${{ matrix.php_version }}\" > /output/grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.txt | |
| echo \"gRPC Version: ${GRPC_VERSION}\" >> /output/grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.txt | |
| echo \"Platform: Linux ${{ matrix.arch }}\" >> /output/grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.txt | |
| echo \"Build Date: \$(date -u)\" >> /output/grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.txt | |
| " | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }} | |
| path: | | |
| grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.so | |
| grpc-php${{ matrix.php_version }}-linux-${{ matrix.arch }}.txt | |
| build-macos: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: ['macos-13', 'macos-14'] # macos-13=x86_64, macos-14=arm64 | |
| php_version: ['8.0', '8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php_version }} | |
| extensions: none | |
| tools: pecl | |
| - name: Build gRPC extension | |
| run: | | |
| pecl install grpc-${GRPC_VERSION} | |
| # Get extension directory and copy the built extension | |
| PHP_EXT_DIR=$(php-config --extension-dir) | |
| ARCH=${{ matrix.os == 'macos-14' && 'arm64' || 'x86_64' }} | |
| cp $PHP_EXT_DIR/grpc.so grpc-php${{ matrix.php_version }}-macos-$ARCH.so | |
| # Create metadata | |
| echo "PHP Version: ${{ matrix.php_version }}" > grpc-php${{ matrix.php_version }}-macos-$ARCH.txt | |
| echo "gRPC Version: ${GRPC_VERSION}" >> grpc-php${{ matrix.php_version }}-macos-$ARCH.txt | |
| echo "Platform: macOS $ARCH" >> grpc-php${{ matrix.php_version }}-macos-$ARCH.txt | |
| echo "Build Date: $(date -u)" >> grpc-php${{ matrix.php_version }}-macos-$ARCH.txt | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: grpc-php${{ matrix.php_version }}-macos-${{ matrix.os == 'macos-14' && 'arm64' || 'x86_64' }} | |
| path: | | |
| grpc-php${{ matrix.php_version }}-macos-*.so | |
| grpc-php${{ matrix.php_version }}-macos-*.txt | |
| release: | |
| needs: [build-linux, build-macos] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: artifacts/**/* | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |