feat: grpc builder追加 #5
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 and Protobuf PHP Extensions | |
| 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-x86_64: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php_version: ['8.0', '8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build gRPC and Protobuf extensions | |
| run: | | |
| docker run --rm \ | |
| --platform linux/amd64 \ | |
| -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 and Protobuf | |
| pecl install grpc-${GRPC_VERSION} | |
| pecl install protobuf | |
| # Copy the built extensions | |
| PHP_EXT_DIR=\$(php-config --extension-dir) | |
| cp \$PHP_EXT_DIR/grpc.so /output/grpc-php${{ matrix.php_version }}-linux-x86_64.so | |
| cp \$PHP_EXT_DIR/protobuf.so /output/protobuf-php${{ matrix.php_version }}-linux-x86_64.so | |
| # Get protobuf version | |
| PROTOBUF_VERSION=\$(php -r \"echo phpversion('protobuf');\" -dextension=protobuf.so) | |
| # Create metadata for gRPC | |
| echo \"PHP Version: ${{ matrix.php_version }}\" > /output/grpc-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"gRPC Version: ${GRPC_VERSION}\" >> /output/grpc-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"Platform: Linux x86_64\" >> /output/grpc-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"Build Date: \$(date -u)\" >> /output/grpc-php${{ matrix.php_version }}-linux-x86_64.txt | |
| # Create metadata for Protobuf | |
| echo \"PHP Version: ${{ matrix.php_version }}\" > /output/protobuf-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"Protobuf Version: \$PROTOBUF_VERSION\" >> /output/protobuf-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"Platform: Linux x86_64\" >> /output/protobuf-php${{ matrix.php_version }}-linux-x86_64.txt | |
| echo \"Build Date: \$(date -u)\" >> /output/protobuf-php${{ matrix.php_version }}-linux-x86_64.txt | |
| " | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extensions-php${{ matrix.php_version }}-linux-x86_64 | |
| path: | | |
| grpc-php${{ matrix.php_version }}-linux-x86_64.so | |
| grpc-php${{ matrix.php_version }}-linux-x86_64.txt | |
| protobuf-php${{ matrix.php_version }}-linux-x86_64.so | |
| protobuf-php${{ matrix.php_version }}-linux-x86_64.txt | |
| build-linux-aarch64: | |
| runs-on: ubuntu-24.04-arm64 | |
| strategy: | |
| matrix: | |
| php_version: ['8.0', '8.1', '8.2', '8.3', '8.4'] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build gRPC and Protobuf extensions | |
| run: | | |
| docker run --rm \ | |
| --platform linux/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 and Protobuf | |
| pecl install grpc-${GRPC_VERSION} | |
| pecl install protobuf | |
| # Copy the built extensions | |
| PHP_EXT_DIR=\$(php-config --extension-dir) | |
| cp \$PHP_EXT_DIR/grpc.so /output/grpc-php${{ matrix.php_version }}-linux-aarch64.so | |
| cp \$PHP_EXT_DIR/protobuf.so /output/protobuf-php${{ matrix.php_version }}-linux-aarch64.so | |
| # Get protobuf version | |
| PROTOBUF_VERSION=\$(php -r \"echo phpversion('protobuf');\" -dextension=protobuf.so) | |
| # Create metadata for gRPC | |
| echo \"PHP Version: ${{ matrix.php_version }}\" > /output/grpc-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"gRPC Version: ${GRPC_VERSION}\" >> /output/grpc-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"Platform: Linux aarch64\" >> /output/grpc-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"Build Date: \$(date -u)\" >> /output/grpc-php${{ matrix.php_version }}-linux-aarch64.txt | |
| # Create metadata for Protobuf | |
| echo \"PHP Version: ${{ matrix.php_version }}\" > /output/protobuf-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"Protobuf Version: \$PROTOBUF_VERSION\" >> /output/protobuf-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"Platform: Linux aarch64\" >> /output/protobuf-php${{ matrix.php_version }}-linux-aarch64.txt | |
| echo \"Build Date: \$(date -u)\" >> /output/protobuf-php${{ matrix.php_version }}-linux-aarch64.txt | |
| " | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extensions-php${{ matrix.php_version }}-linux-aarch64 | |
| path: | | |
| grpc-php${{ matrix.php_version }}-linux-aarch64.so | |
| grpc-php${{ matrix.php_version }}-linux-aarch64.txt | |
| protobuf-php${{ matrix.php_version }}-linux-aarch64.so | |
| protobuf-php${{ matrix.php_version }}-linux-aarch64.txt | |
| release: | |
| needs: [build-linux-x86_64] | |
| 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 }} |