Skip to content

Build PHP

Build PHP #39

Workflow file for this run

name: Build PHP
on:
workflow_dispatch:
inputs:
selectos:
required: true
description: Build target OS
default: 'linux-x86_64'
type: choice
options:
- 'linux-x86_64'
- 'linux-aarch64'
- 'linux-x86_64-glibc'
- 'linux-aarch64-glibc'
- 'macos-x86_64'
- 'macos-aarch64'
- 'windows'
php-version:
required: true
description: PHP version to compile
default: '8.4'
type: choice
options:
- '8.4'
- '8.3'
- '8.2'
jobs:
unix-static-build:
if: ${{ inputs.selectos != 'windows' }}
uses: yoramdelangen/static-php-cli/.github/workflows/build-unix.yml@feat/workflow-call-with-vendor-mode
with:
os: ${{ inputs.selectos }}
php-version: ${{ inputs.php-version }}
extensions: 'odbc,pdo_odbc,bcmath,calendar,ctype,curl,dba,exif,fileinfo,filter,gd,intl,libxml,mbregex,mbstring,msgpack,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,sqlsrv,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,snowflake,rustypipewire'
vendor-mode: true
windows-build:
if: ${{ inputs.selectos == 'windows' }}
name: build ${{ inputs.php-version }} on Windows x86_64
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# Cache composer dependencies
- id: cache-composer-deps
uses: actions/cache@v4
with:
path: vendor
key: composer-dependencies
# If there's no Composer cache, install dependencies
- if: steps.cache-composer-deps.outputs.cache-hit != 'true'
run: composer update --no-dev --classmap-authoritative
env:
COMPOSER_AUTH: |
{
"github-oauth": {
"github.com": "${{ secrets.GITHUB_TOKEN }}"
}
}
- name: Generate hashed key for download cache
shell: bash
run: |
INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}')
echo "INPUT_HASH=${INPUT_HASH}" >> "$GITHUB_ENV"
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: php-${{ env.INPUT_HASH }}
# With or without debug
# defaults:
- name: Define default environments
run: |
echo "SPC_BUILD_DEBUG=--debug" >> $env:GITHUB_ENV
echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV
echo "SPC_BUILD_CLI=--build-cli" >> $env:GITHUB_ENV
echo "PHP_EXTENSIONS=bcmath,bz2,curl,mbstring,msgpack,mysqli,mysqlnd,odbc,opcache,openssl,pdo,pdo_mysql,pdo_odbc,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,redis,sockets,sodium,sqlite3,sqlsrv,zip,zlib,rustypipewire" >> $env:GITHUB_ENV
- run: vendor/bin/spc doctor
# If there's no dependencies cache, fetch sources, with or without debug
- if: steps.cache-download.outputs.cache-hit != 'true'
run: vendor/bin/spc download --with-php="${{ inputs.php-version }}" --for-extensions="${{ env.PHP_EXTENSIONS }}" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }}
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Run build command
- run: vendor/bin/spc build "${{ env.PHP_EXTENSIONS }}" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} --no-strip
- run: ls
# Upload cli executable
- # if: ${{ inputs.build-cli == true }}
uses: actions/upload-artifact@v4
with:
name: php-${{ inputs.version }}
path: buildroot/bin/php.exe
# Upload micro self-extracted executable
- if: ${{ inputs.build-micro == true }}
uses: actions/upload-artifact@v4
with:
name: micro-${{ inputs.version }}
path: buildroot/bin/micro.sfx
# Upload extensions metadata
- uses: actions/upload-artifact@v4
with:
name: license-files
path: buildroot/license/
- uses: actions/upload-artifact@v4
with:
name: build-meta
path: |
buildroot/build-extensions.json
buildroot/build-libraries.json