Build Self-Hosted PHP Binary (Unix) #1
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 Self-Hosted PHP Binary (Unix) | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
build-release-artifacts: | ||
name: "Build ${{ matrix.php-version }}-${{ matrix.combination }} on ${{ matrix.runner }}" | ||
runs-on: ${{ matrix.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-version: | ||
- "8.0" | ||
- "8.1" | ||
- "8.2" | ||
- "8.3" | ||
runner: | ||
- "ubuntu-latest" | ||
- "macos-13" | ||
- "ubuntu-20.04" | ||
- "macos-14" | ||
combination: | ||
- minimal | ||
- bulk | ||
- common | ||
steps: | ||
- name: "Process env string" | ||
id: process-env | ||
shell: bash | ||
run: | | ||
Check failure on line 31 in .github/workflows/build-php-unix.yml GitHub Actions / Build Self-Hosted PHP Binary (Unix)Invalid workflow file
|
||
case "${{ martix.combination }}" in | ||
minimal) | ||
echo "EXTENSIONS=pcntl,posix,mbstring,tokenizer,phar" >> "$GITHUB_OUTPUT" | ||
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_MINIMAL }}" >> "$GITHUB_OUTPUT" | ||
;; | ||
common) | ||
echo "EXTENSIONS=bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip" >> "$GITHUB_OUTPUT" | ||
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET }}" >> "$GITHUB_OUTPUT" | ||
;; | ||
bulk) | ||
echo "EXTENSIONS=apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib" >> "$GITHUB_OUTPUT" | ||
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_BULK }}" >> "$GITHUB_OUTPUT" | ||
;; | ||
esac | ||
case "${{ matrix.runner }}" in | ||
ubuntu-latest) | ||
echo "OS=linux" >> "$GITHUB_OUTPUT" | ||
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" | ||
echo "CMD=bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" | ||
;; | ||
ubuntu-20.04) | ||
echo "OS=linux" >> "$GITHUB_OUTPUT" | ||
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" | ||
echo CMD="SPC_USE_ARCH=aarch64 bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" | ||
;; | ||
windows-2019) | ||
echo "OS=windows" >> "$GITHUB_OUTPUT" | ||
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" | ||
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" | ||
;; | ||
macos-13) | ||
echo "OS=macos" >> "$GITHUB_OUTPUT" | ||
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" | ||
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" | ||
;; | ||
macos-14) | ||
echo "OS=macos" >> "$GITHUB_OUTPUT" | ||
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" | ||
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" | ||
;; | ||
esac | ||
- name: "Checkout remote" | ||
if: github.repository != 'crazywhalecc/static-php-cli' | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: crazywhalecc/static-php-cli | ||
ref: pre-built-libs | ||
- name: "Setup PHP" | ||
if: matrix.runner != 'ubuntu-20.04' | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.2 | ||
tools: pecl, composer | ||
extensions: curl, openssl, mbstring | ||
ini-values: memory_limit=-1 | ||
- name: "Cache composer packages" | ||
id: composer-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php | ||
# Cache downloaded source | ||
- id: cache-download | ||
uses: actions/cache@v4 | ||
with: | ||
path: downloads | ||
key: pack-lib-dependencies-${{ matrix.combination }}-${{ matrix.php-version }} | ||
- name: "Install Dependencies" | ||
if: matrix.runner != 'ubuntu-20.04' | ||
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev | ||
- run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix | ||
# If there's no dependencies cache, fetch sources | ||
- name: "Download sources" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} | ||
run: ${{ steps.process-env.outputs.CMD }} download --with-php=${{ matrix.php-version }} --for-extensions=${{ steps.process-env.outputs.EXTENSIONS }} --retry=5 --prefer-pre-built | ||
- name: "Build library: ${{ matrix.library }}" | ||
run: | | ||
if [ "${{ steps.process-env.outputs.OS }}" = "linux" ]; then | ||
${{ steps.process-env.outputs.CMD }} install-pkg upx | ||
UPX=--with-upx-pack | ||
fi | ||
${{ steps.process-env.outputs.CMD }} build --build-cli --build-micro --build-fpm ${{ steps.process-env.outputs.EXTENSIONS }} --debug $UPX | ||
PHPVER=$(cat source/php-src/main/php_version.h | grep "PHP_VERSION " | awk -F\" '{print $2}') | ||
mkdir dist/ | ||
tar -czf dist/php-$PHPVER-cli-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ php | ||
tar -czf dist/php-$PHPVER-micro-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ micro.sfx | ||
tar -czf dist/php-$PHPVER-fpm-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ php-fpm | ||
if [ "${{ matrix.php-version }}" == "8.3" ] && [ "${{ matrix.runner }}" == "ubuntu-latest" ]; then | ||
cp -r buildroot/license dist/ | ||
cp buildroot/build-extensions.json dist/ | ||
cp buildroot/build-libraries.json dist/ | ||
fi | ||
- name: Deploy to Zhamao Server | ||
uses: easingthemes/ssh-deploy@main | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} | ||
ARGS: "-rltgoDzvO" | ||
SOURCE: "dist/" | ||
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }} | ||
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }} | ||
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }} | ||
TARGET: ${{ steps.process-env.outputs.DEPLOY_TARGET }} | ||
- name: "Upload Artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: php-${{ matrix.php-version }}-${{ steps.process-env.outputs.OS }} | ||
path: | | ||
buildroot/bin/php | ||
buildroot/bin/php-fpm | ||
buildroot/bin/micro.sfx | ||
if-no-files-found: error |