Build PHP #2090
This file contains 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 PHP | |
on: | |
push: | |
pull_request: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
build-mode: | |
description: 'Build mode: --build-all or --build--new' | |
default: '--build-new' | |
required: false | |
php-source: | |
description: 'PHP source: --web-php or --php-src' | |
default: '--web-php' | |
required: false | |
php-versions: | |
description: 'PHP version to build' | |
default: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4' | |
required: false | |
container-os-versions: | |
description: 'OS versions to build on' | |
default: 'ubuntu:20.04 ubuntu:22.04 debian:10 debian:11 debian:12' | |
required: false | |
schedule: | |
- cron: '0 0 1-31/2 * *' | |
env: | |
CONTAINER_OS_LIST: ubuntu:20.04 ubuntu:22.04 ubuntu:24.04 debian:10 debian:11 debian:12 | |
RUNNER_OS_LIST: ubuntu-20.04 ubuntu-22.04 | |
PHP_LIST: 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 | |
SAPI_LIST: apache2 cgi cli embed fpm phpdbg | |
BUILD_LIST: nts zts | |
jobs: | |
get-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
container_only: ${{ steps.set-matrix.outputs.container_only }} | |
container_os_matrix: ${{ steps.set-matrix.outputs.container_os_matrix }} | |
runner_os_matrix: ${{ steps.set-matrix.outputs.runner_os_matrix }} | |
test_container_os_matrix: ${{ steps.set-matrix.outputs.test_container_os_matrix }} | |
test_runner_os_matrix: ${{ steps.set-matrix.outputs.test_runner_os_matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get matrix | |
id: set-matrix | |
env: | |
COMMIT: ${{ github.event.head_commit.message || github.event.inputs.build-mode }} | |
CONTAINER_OS_LIST: ${{ github.event.inputs.container-os-versions || env.CONTAINER_OS_LIST }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RUNNER_OS_LIST: ${{ env.RUNNER_OS_LIST }} | |
PHP_LIST: ${{ github.event.inputs.php-versions || env.PHP_LIST }} | |
PHP_SOURCE: ${{ github.event.inputs.php-source }} | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
BUILD_LIST: ${{ env.BUILD_LIST }} | |
run: bash scripts/get-matrix.sh | |
build: | |
needs: get-matrix | |
if: "!contains(github.event.head_commit.message, 'skip-build')" | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.get-matrix.outputs.container_os_matrix)}} | |
env: | |
BUILD: ${{ matrix.build }} | |
GITHUB_MESSAGE: ${{ github.event.head_commit.message || github.event.inputs.build-mode }} | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_VERSION: ${{ matrix.php-version }} | |
PHP_SOURCE: ${{ github.event.inputs.php-source }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install required packages | |
run: bash scripts/install-requirements.sh | |
env: | |
BUILD: ${{ matrix.build }} | |
- name: Build and package apache2 | |
if: contains(env.SAPI_LIST, 'apache2') | |
run: bash scripts/build.sh build_sapi apache2 | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Build and package cgi | |
if: contains(env.SAPI_LIST, 'cgi') | |
run: bash scripts/build.sh build_sapi cgi | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Build and package cli | |
if: contains(env.SAPI_LIST, 'cli') | |
run: bash scripts/build.sh build_sapi cli | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Build and package embed | |
if: contains(env.SAPI_LIST, 'embed') | |
run: bash scripts/build.sh build_sapi embed | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Build and package fpm | |
if: contains(env.SAPI_LIST, 'fpm') | |
run: bash scripts/build.sh build_sapi fpm | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Build and package phpdbg | |
if: contains(env.SAPI_LIST, 'phpdbg') | |
run: bash scripts/build.sh build_sapi phpdbg | |
env: | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: php-sapi${{ matrix.php-version }}-${{ matrix.build }}+${{ matrix.dist }}-${{ matrix.dist-version }} | |
path: /tmp/debian/*.zst | |
merge: | |
needs: [get-matrix, build] | |
if: "!contains(github.event.head_commit.message, 'skip-merge')" | |
container: ${{ matrix.container }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.get-matrix.outputs.container_os_matrix)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install required packages | |
run: bash scripts/install-requirements.sh | |
env: | |
BUILD: ${{ matrix.build }} | |
PHP_VERSION: ${{ matrix.php-version }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: php-sapi${{ matrix.php-version }}-${{ matrix.build }}+${{ matrix.dist }}-${{ matrix.dist-version }} | |
path: /tmp | |
- name: Stage builds | |
shell: bash | |
run: | | |
mkdir -p /tmp/debian | |
for sapi_build in /tmp/*.zst; do | |
tar -I zstd -xf "$sapi_build" -C /tmp/debian | |
rm -f "$sapi_build" | |
done | |
- name: Build and package | |
run: bash scripts/build.sh merge | |
env: | |
BUILD: ${{ matrix.build }} | |
SAPI_LIST: ${{ env.SAPI_LIST }} | |
GITHUB_USER: ${{ github.repository_owner }} | |
GITHUB_MESSAGE: ${{ github.event.head_commit.message || github.event.inputs.build-mode }} | |
GITHUB_NAME: 'Shivam Mathur' | |
GITHUB_EMAIL: ${{ secrets.email }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
GITHUB_WORKSPACE: ${{ github.workspace }} | |
PHP_VERSION: ${{ matrix.php-version }} | |
PHP_SOURCE: ${{ github.event.inputs.php-source }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.build }}+${{ matrix.dist }} | |
path: | | |
/tmp/*.xz | |
/tmp/*.zst | |
- name: Check php-cli version | |
run: | | |
php -v | |
php -r "if(strpos(phpversion(), '${{ matrix.php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" | |
- name: Check php-cgi version | |
run: php-cgi -v | |
- name: Check php-fpm version | |
run: php-fpm -v && php-fpm -t | |
- name: Check phpdbg version | |
run: phpdbg -V | |
- name: Check pecl version | |
run: pecl -V | |
- name: Check php-config version | |
run: php-config --version | |
- name: Check phpize version | |
run: phpize -v | |
- name: Check php extensions | |
run: bash scripts/test_extensions.sh | |
env: | |
PHP_VERSION: ${{ matrix.php-version }} | |
local-test: | |
needs: [merge, build, get-matrix] | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-local-test')" | |
container: ${{ matrix.container }} | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.get-matrix.outputs.test_container_os_matrix)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.build }}+${{ matrix.dist }} | |
path: /tmp | |
- name: Install PHP | |
run: | | |
sed -i '/download/d' scripts/install.sh | |
bash scripts/install.sh ${{ matrix.php-version }} local ${{ matrix.debug }} ${{ matrix.build }} | |
- name: Test | |
run: | | |
php -v | |
php -r "if(strpos(phpversion(), '${{ matrix.php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" | |
php -m | |
- name: Check GD support | |
run: php -r "print_r(gd_info());" | |
- name: Test pecl | |
run: bash scripts/test_pecl.sh | |
env: | |
PHP_VERSION: ${{ matrix.php-version }} | |
- name: Check SAPI | |
run: bash scripts/test_sapi.sh | |
env: | |
PHP_VERSION: ${{ matrix.php-version }} | |
github-test: | |
needs: [merge, build, get-matrix] | |
runs-on: ${{ matrix.os }} | |
if: "!contains(github.event.head_commit.message, 'skip-github-test') && contains(needs.get-matrix.outputs.container_only, 'false')" | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.get-matrix.outputs.test_runner_os_matrix)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: php${{ matrix.php-version }}-${{ matrix.build }}+ubuntu | |
path: /tmp | |
- name: Install PHP | |
run: | | |
sed -i '/download/d' scripts/install.sh | |
bash scripts/install.sh ${{ matrix.php-version }} github ${{ matrix.debug }} ${{ matrix.build }} | |
- name: Test | |
run: | | |
php -v | |
php -r "if(strpos(phpversion(), '${{ matrix.php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" | |
php -m | |
- name: Test pecl | |
run: bash scripts/test_pecl.sh | |
env: | |
PHP_VERSION: ${{ matrix.php-version }} | |
- name: Check SAPI | |
run: bash scripts/test_sapi.sh | |
env: | |
PHP_VERSION: ${{ matrix.php-version }} | |
release-container-only: | |
needs: [get-matrix, local-test] | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-release') && contains(needs.get-matrix.outputs.container_only, 'true')" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Create builds directory | |
run: mkdir builds | |
- uses: actions/download-artifact@v3 | |
with: | |
path: builds | |
- name: Release | |
run: bash scripts/release.sh | |
env: | |
GITHUB_MESSAGE: ${{ github.event.head_commit.message || github.event.inputs.build-mode }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_LIST: ${{ github.event.inputs.php-versions || env.PHP_LIST }} | |
PHP_SOURCE: ${{ github.event.inputs.php-source }} | |
release: | |
needs: [get-matrix, local-test, github-test] | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-release') && contains(needs.get-matrix.outputs.container_only, 'false')" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Create builds directory | |
run: mkdir builds | |
- uses: actions/download-artifact@v3 | |
with: | |
path: builds | |
- name: Release | |
run: bash scripts/release.sh | |
env: | |
GITHUB_MESSAGE: ${{ github.event.head_commit.message || github.event.inputs.build-mode }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_LIST: ${{ github.event.inputs.php-versions || env.PHP_LIST }} | |
PHP_SOURCE: ${{ github.event.inputs.php-source }} |