├── .github └── workflows │ ├── build-php-unix.yml │ ├── build-php-windows.yml │ ├── download-cache.yml │ ├── ext-matrix-tests-php80.yml │ ├── ext-matrix-tests-php84.yml │ └── pack-libs.yml ├── README.md └── composer.json /.github/workflows/build-php-unix.yml: -------------------------------------------------------------------------------- 1 | name: Build Self-Hosted PHP Binary (Unix) 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 1 */3 * *" 7 | 8 | jobs: 9 | build-release-artifacts: 10 | name: "Build ${{ matrix.php-version }}-${{ matrix.combination }} on ${{ matrix.runner }}" 11 | runs-on: ${{ matrix.runner }} 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | php-version: 16 | - "8.1" 17 | - "8.2" 18 | - "8.3" 19 | - "8.4" 20 | runner: 21 | - "ubuntu-latest" 22 | - "macos-13" 23 | - "ubuntu-24.04-arm" 24 | - "macos-14" 25 | combination: 26 | - minimal 27 | - bulk 28 | - common 29 | steps: 30 | - name: "Process env string" 31 | id: process-env 32 | shell: bash 33 | run: | 34 | case "${{ matrix.combination }}" in 35 | minimal) 36 | echo "EXTENSIONS=pcntl,posix,mbstring,filter,tokenizer,phar" >> "$GITHUB_OUTPUT" 37 | echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_MINIMAL }}" >> "$GITHUB_OUTPUT" 38 | ;; 39 | common) 40 | 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" 41 | echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET }}" >> "$GITHUB_OUTPUT" 42 | ;; 43 | bulk) 44 | 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" 45 | echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_BULK }}" >> "$GITHUB_OUTPUT" 46 | ;; 47 | esac 48 | 49 | case "${{ matrix.runner }}" in 50 | ubuntu-latest) 51 | echo "OS=linux" >> "$GITHUB_OUTPUT" 52 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 53 | echo "CMD=bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" 54 | ;; 55 | ubuntu-24.04-arm) 56 | echo "OS=linux" >> "$GITHUB_OUTPUT" 57 | echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" 58 | echo CMD="bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" 59 | ;; 60 | windows-2019) 61 | echo "OS=windows" >> "$GITHUB_OUTPUT" 62 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 63 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 64 | ;; 65 | macos-13) 66 | echo "OS=macos" >> "$GITHUB_OUTPUT" 67 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 68 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 69 | ;; 70 | macos-14) 71 | echo "OS=macos" >> "$GITHUB_OUTPUT" 72 | echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" 73 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 74 | ;; 75 | esac 76 | 77 | - name: "Checkout remote" 78 | if: github.repository != 'crazywhalecc/static-php-cli' 79 | uses: actions/checkout@v4 80 | with: 81 | repository: crazywhalecc/static-php-cli 82 | ref: main 83 | 84 | - name: "Setup PHP" 85 | if: matrix.runner != 'ubuntu-24.04-arm' && matrix.runner != 'ubuntu-latest' 86 | uses: shivammathur/setup-php@v2 87 | with: 88 | php-version: 8.4 89 | tools: pecl, composer 90 | extensions: curl, openssl, mbstring, filter 91 | ini-values: memory_limit=-1 92 | 93 | - name: "Cache composer packages" 94 | id: composer-cache 95 | uses: actions/cache@v4 96 | with: 97 | path: vendor 98 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 99 | restore-keys: | 100 | ${{ runner.os }}-php 101 | 102 | # Cache downloaded source 103 | - id: cache-download 104 | uses: actions/cache@v4 105 | with: 106 | path: downloads 107 | key: pack-lib-dependencies-${{ matrix.combination }}-${{ matrix.php-version }}-${{ matrix.runner }} 108 | 109 | - name: "Install Dependencies" 110 | if: matrix.runner != 'ubuntu-24.04-arm' && matrix.runner != 'ubuntu-latest' 111 | run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev 112 | 113 | - run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix 114 | 115 | # If there's no dependencies cache, fetch sources 116 | - name: "Download sources" 117 | env: 118 | GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} 119 | run: ${{ steps.process-env.outputs.CMD }} download --with-php=${{ matrix.php-version }} --for-extensions=${{ steps.process-env.outputs.EXTENSIONS }} --retry=5 --prefer-pre-built 120 | 121 | - name: "Build library: ${{ matrix.library }}" 122 | run: | 123 | if [ "${{ steps.process-env.outputs.OS }}" = "linux" ]; then 124 | ${{ steps.process-env.outputs.CMD }} install-pkg upx 125 | UPX=--with-upx-pack 126 | fi 127 | 128 | ${{ steps.process-env.outputs.CMD }} build --build-cli --build-micro --build-fpm ${{ steps.process-env.outputs.EXTENSIONS }} --debug $UPX 129 | 130 | # Copy out from buildroot, because docker build has different permission 131 | mkdir -p tmp_dist/ 132 | cp buildroot/bin/php tmp_dist/ 133 | cp buildroot/bin/micro.sfx tmp_dist/ 134 | cp buildroot/bin/php-fpm tmp_dist/ 135 | 136 | PHPVER=$(cat source/php-src/main/php_version.h | grep "PHP_VERSION " | awk -F\" '{print $2}') 137 | 138 | if [ ! -d "dist" ]; then 139 | mkdir dist/ 140 | fi 141 | 142 | sudo chmod -R 777 dist 143 | 144 | tar -czf dist/php-$PHPVER-cli-${{ steps.process-env.outputs.OS }}-${{ steps.process-env.outputs.ARCH }}.tar.gz -C tmp_dist/ php 145 | tar -czf dist/php-$PHPVER-micro-${{ steps.process-env.outputs.OS }}-${{ steps.process-env.outputs.ARCH }}.tar.gz -C tmp_dist/ micro.sfx 146 | tar -czf dist/php-$PHPVER-fpm-${{ steps.process-env.outputs.OS }}-${{ steps.process-env.outputs.ARCH }}.tar.gz -C tmp_dist/ php-fpm 147 | if [ "${{ matrix.php-version }}" == "8.4" ] && [ "${{ matrix.runner }}" == "ubuntu-latest" ]; then 148 | cp -r buildroot/license dist/ 149 | cp buildroot/build-extensions.json dist/ 150 | cp buildroot/build-libraries.json dist/ 151 | echo -e "# Note\n\nCurrent distribution uses extensions:\n\n${{ steps.process-env.outputs.EXTENSIONS }}\n\nUsing compile command:\n\n bin/spc build --build-cli --build-micro --build-fpm ${{ steps.process-env.outputs.EXTENSIONS }} --debug --with-upx-pack" > dist/README.txt 152 | fi 153 | 154 | - name: "Deploy to self-hosted OSS" 155 | uses: static-php/upload-s3-action@v1.0.0 156 | with: 157 | aws_key_id: ${{ secrets.AWS_KEY_ID }} 158 | aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 159 | aws_bucket: ${{ secrets.AWS_BUCKET }} 160 | source_dir: "dist/" 161 | destination_dir: static-php-cli/${{ matrix.combination }}/ 162 | endpoint: ${{ secrets.AWS_ENDPOINT }} 163 | 164 | - name: "Upload Artifact" 165 | uses: actions/upload-artifact@v4 166 | with: 167 | name: php-${{ matrix.php-version }}-${{ matrix.combination }}-${{ steps.process-env.outputs.OS }}-${{ steps.process-env.outputs.ARCH }} 168 | path: | 169 | tmp_dist/php 170 | tmp_dist/php-fpm 171 | tmp_dist/micro.sfx 172 | if-no-files-found: error 173 | -------------------------------------------------------------------------------- /.github/workflows/build-php-windows.yml: -------------------------------------------------------------------------------- 1 | name: Build Self-Hosted PHP Binary (Windows) 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 1 */3 * *" 7 | 8 | jobs: 9 | build-release-artifacts: 10 | name: "Build ${{ matrix.php-version }}-${{ matrix.combination }} on ${{ matrix.runner }}" 11 | runs-on: ${{ matrix.runner }} 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | php-version: 16 | - "8.1" 17 | - "8.2" 18 | - "8.3" 19 | - "8.4" 20 | runner: 21 | - "windows-latest" 22 | combination: 23 | - spc-min 24 | - spc-max 25 | 26 | steps: 27 | - name: "Process env string" 28 | id: process-env 29 | run: | 30 | switch ("${{ matrix.combination }}") { 31 | "spc-min" { 32 | Add-Content -Path $env:GITHUB_OUTPUT -Value "EXTENSIONS=ctype,fileinfo,mbstring,tokenizer,phar" 33 | Add-Content -Path $env:GITHUB_OUTPUT -Value "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MIN }}" 34 | } 35 | "spc-max" { 36 | Add-Content -Path $env:GITHUB_OUTPUT -Value "EXTENSIONS=amqp,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib" 37 | Add-Content -Path $env:GITHUB_OUTPUT -Value "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MAX }}" 38 | } 39 | } 40 | 41 | switch ("${{ matrix.runner }}") { 42 | "windows-latest" { 43 | Add-Content -Path $env:GITHUB_OUTPUT -Value "OS=windows" 44 | Add-Content -Path $env:GITHUB_OUTPUT -Value "ARCH=x86_64" 45 | Add-Content -Path $env:GITHUB_OUTPUT -Value "CMD=bin/spc" 46 | } 47 | } 48 | 49 | - name: "Checkout remote" 50 | if: github.repository != 'crazywhalecc/static-php-cli' 51 | uses: actions/checkout@v4 52 | with: 53 | repository: crazywhalecc/static-php-cli 54 | ref: main 55 | 56 | - name: "Setup PHP" 57 | uses: shivammathur/setup-php@v2 58 | with: 59 | php-version: 8.4 60 | tools: pecl, composer 61 | extensions: curl, openssl, mbstring, filter 62 | ini-values: memory_limit=-1 63 | 64 | - name: "Cache composer packages" 65 | id: composer-cache 66 | uses: actions/cache@v4 67 | with: 68 | path: vendor 69 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 70 | restore-keys: | 71 | ${{ runner.os }}-php 72 | 73 | # Cache downloaded source 74 | - id: cache-download 75 | uses: actions/cache@v4 76 | with: 77 | path: downloads 78 | key: pack-lib-dependencies-${{ matrix.combination }}-${{ matrix.php-version }}-${{ matrix.runner }} 79 | 80 | - name: "Install Dependencies" 81 | run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev 82 | 83 | - name: "Validate SPC powershell script" 84 | run: ${{ steps.process-env.outputs.CMD }} --version 85 | 86 | - name: "Run Build Tests (doctor)" 87 | run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix 88 | 89 | # If there's no dependencies cache, fetch sources 90 | - name: "Download sources" 91 | env: 92 | GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} 93 | run: ${{ steps.process-env.outputs.CMD }} download --with-php=${{ matrix.php-version }} --for-extensions="${{ steps.process-env.outputs.EXTENSIONS }}" --retry=5 --prefer-pre-built 94 | 95 | - name: "Build extensions: ${{ steps.process-env.outputs.EXTENSIONS }}" 96 | run: | 97 | ${{ steps.process-env.outputs.CMD }} doctor --auto-fix 98 | ${{ steps.process-env.outputs.CMD }} install-pkg upx 99 | 100 | ${{ steps.process-env.outputs.CMD }} build --build-cli --build-micro "${{ steps.process-env.outputs.EXTENSIONS }}" --debug --with-upx-pack 101 | 102 | $PHPVER = ${{ steps.process-env.outputs.CMD }} dev:php-ver 103 | New-Item -ItemType Directory -Force -Path dist 104 | Compress-Archive -Path "buildroot\bin\php.exe" -DestinationPath "dist\php-$PHPVER-cli-win.zip" 105 | Compress-Archive -Path "buildroot\bin\micro.sfx" -DestinationPath "dist\php-$PHPVER-micro-win.zip" 106 | ls dist 107 | echo ("PHPVER=" + $PHPVER) >> $env:GITHUB_ENV 108 | 109 | - name: "Add README for ${{ matrix.combination }}" 110 | if: ${{ matrix.php-version == '8.4' }} 111 | shell: bash 112 | run: | 113 | echo -e "# Note\n\nCurrent distribution uses extensions:\n\n${{ steps.process-env.outputs.EXTENSIONS }}\n\nUsing compile command:\n\n bin/spc build --build-cli --build-micro \"${{ steps.process-env.outputs.EXTENSIONS }}\" --debug --with-upx-pack" > dist/README.txt 114 | 115 | - name: "Deploy to self-hosted OSS" 116 | uses: static-php/upload-s3-action@v1.0.0 117 | with: 118 | aws_key_id: ${{ secrets.AWS_KEY_ID }} 119 | aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 120 | aws_bucket: ${{ secrets.AWS_BUCKET }} 121 | source_dir: "dist/" 122 | destination_dir: static-php-cli/windows/${{ matrix.combination }}/ 123 | endpoint: ${{ secrets.AWS_ENDPOINT }} 124 | 125 | - name: "Upload Artifact" 126 | uses: actions/upload-artifact@v4 127 | with: 128 | name: php-${{ matrix.php-version }}-windows-${{ matrix.combination }} 129 | path: | 130 | buildroot/bin/php.exe 131 | buildroot/bin/micro.sfx 132 | if-no-files-found: error 133 | 134 | -------------------------------------------------------------------------------- /.github/workflows/download-cache.yml: -------------------------------------------------------------------------------- 1 | name: "Mirror sources to dl.static-php.dev" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 1 */3 * *" 7 | 8 | env: 9 | GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} 10 | 11 | jobs: 12 | # define 13 | define-matrix: 14 | name: "Generate source matrix" 15 | runs-on: ubuntu-latest 16 | outputs: 17 | sources: ${{ steps.step1.outputs.sources }} 18 | steps: 19 | - name: "Checkout" 20 | uses: "actions/checkout@v4" 21 | with: 22 | repository: crazywhalecc/static-php-cli 23 | 24 | - name: "Create Matrix Variable" 25 | id: step1 26 | run: | 27 | VALUE=$(cat config/source.json | jq -M -c keys) 28 | echo 'sources='"$VALUE" >> "$GITHUB_OUTPUT" 29 | 30 | # parse 31 | download-source: 32 | name: "Download ${{ matrix.source }}" 33 | runs-on: ubuntu-latest 34 | needs: define-matrix 35 | timeout-minutes: 60 36 | strategy: 37 | matrix: 38 | source: ${{ fromJSON(needs.define-matrix.outputs.sources) }} 39 | fail-fast: false 40 | steps: 41 | - name: "Checkout" 42 | uses: "actions/checkout@v4" 43 | with: 44 | repository: crazywhalecc/static-php-cli 45 | - name: "Setup static-php environment" 46 | run: | 47 | bin/setup-runtime 48 | bin/php bin/composer install --no-dev --no-ansi -q --no-interaction 49 | - name: "Download source ${{ matrix.source }}" 50 | run: bin/php bin/spc download ${{ matrix.source }} --debug --ignore-cache-sources --no-alt --shallow-clone 51 | - name: "Parse lock file and re-package with file" 52 | run: | 53 | rename_file() { 54 | local src_file="$1" 55 | local target="$2" 56 | local destination_dir="$3" 57 | 58 | if [[ ! -f "$src_file" ]]; then 59 | echo "Error: '$src_file' is not a valid file" >&2 60 | return 1 61 | fi 62 | 63 | if [[ "$src_file" =~ \.tar\.(gz|xz)$ ]]; then 64 | local ext=".tar.${BASH_REMATCH[1]}" 65 | local base_name="${src_file%$ext}" 66 | if [[ -z "$base_name" ]]; then 67 | echo "Error: Invalid filename '$src_file'" >&2 68 | return 1 69 | fi 70 | 71 | elif [[ "$src_file" =~ \.[^./]+$ ]]; then 72 | local ext=".${src_file##*.}" 73 | local base_name="${src_file%.$ext}" 74 | else 75 | echo "Skip: '$src_file' has no extension" >&2 76 | return 0 77 | fi 78 | 79 | local new_name="${target}${ext}" 80 | cp -- "$src_file" "$new_name" 81 | mv "$new_name" "$destination_dir"/ 82 | echo "Renamed: $src_file -> $destination_dir/$new_name" 83 | } 84 | mkdir downloads-mirror-${{ matrix.source }} 85 | SOURCE_TYPE=$(cat downloads/.lock.json | jq -M -c -r '."${{ matrix.source }}".source_type') 86 | if [ "$SOURCE_TYPE" = "archive" ]; then 87 | cd downloads 88 | rename_file $(cat .lock.json | jq -M -c -r '."${{ matrix.source }}".filename') ${{ matrix.source }}-spc-mirror ../downloads-mirror-${{ matrix.source }} 89 | cd .. 90 | else 91 | cd downloads 92 | tar --exclude-vcs -cJvf ${{ matrix.source }}-spc-mirror.txz $(cat .lock.json | jq -M -c -r '."${{ matrix.source }}".dirname') 93 | mv ${{ matrix.source }}-spc-mirror.txz ../downloads-mirror-${{ matrix.source }}/ 94 | cd .. 95 | fi 96 | - name: "Deploy to OSS" 97 | uses: shallwefootball/s3-upload-action@master 98 | with: 99 | aws_key_id: ${{ secrets.AWS_KEY_ID }} 100 | aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 101 | aws_bucket: ${{ secrets.AWS_BUCKET }} 102 | source_dir: downloads-mirror-${{ matrix.source }}/ 103 | destination_dir: static-php-cli/deps/spc-download-mirror/${{ matrix.source }}/ 104 | endpoint: ${{ secrets.AWS_ENDPOINT }} 105 | -------------------------------------------------------------------------------- /.github/workflows/ext-matrix-tests-php80.yml: -------------------------------------------------------------------------------- 1 | name: "Extension matrix tests PHP 8.0" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 2 * * 5" 7 | 8 | jobs: 9 | test: 10 | name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" 11 | runs-on: ${{ matrix.operating-system }} 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | extension: 16 | - apcu 17 | - bcmath 18 | - bz2 19 | - calendar 20 | - ctype 21 | - curl 22 | - dba 23 | - dom 24 | - ds 25 | - event 26 | - exif 27 | - filter 28 | - fileinfo 29 | - ftp 30 | - gd 31 | - gettext 32 | - gmp 33 | - iconv 34 | - igbinary 35 | - imagick 36 | - imap 37 | - intl 38 | - ldap 39 | - mbstring,mbregex 40 | - memcache 41 | - mysqli,mysqlnd,pdo_mysql 42 | #- opcache 43 | - openssl 44 | - password-argon2 45 | - pcntl 46 | - pdo 47 | - pgsql,pdo_pgsql 48 | - phar 49 | - posix 50 | - rar 51 | #- protobuf 52 | - readline 53 | - redis 54 | - session 55 | - shmop 56 | - simdjson 57 | - simplexml,xml 58 | - snappy 59 | - soap 60 | - sockets 61 | - sodium 62 | - sqlite3,pdo_sqlite 63 | - sqlsrv 64 | - ssh2 65 | #- swoole 66 | #- swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite 67 | #- swow 68 | - sysvmsg,sysvsem,sysvshm 69 | - tidy 70 | - tokenizer 71 | #- uv 72 | - xhprof 73 | - xmlwriter,xmlreader 74 | - xsl 75 | - yac 76 | - yaml 77 | - zip 78 | - zlib 79 | - zstd 80 | php-version: 81 | - "8.0" 82 | operating-system: 83 | - "ubuntu-latest" 84 | #- "macos-13" 85 | #- "debian-arm64-self-hosted" 86 | - "macos-14" 87 | 88 | steps: 89 | - name: "Checkout" 90 | uses: "actions/checkout@v4" 91 | 92 | - name: OS type 93 | id: os-type 94 | run: | 95 | OS="" 96 | if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then 97 | OS="linux-x86_64" 98 | elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then 99 | OS="macos-x86_64" 100 | elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then 101 | OS="linux-aarch64" 102 | elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then 103 | OS="macos-aarch64" 104 | fi 105 | echo "OS=$OS" >> $GITHUB_ENV 106 | 107 | - name: Download SPC bin artifact for self-hosted runners 108 | uses: dawidd6/action-download-artifact@v3 109 | with: 110 | repo: crazywhalecc/static-php-cli 111 | branch: main 112 | workflow: release-build.yml 113 | name: "spc-${{ env.OS }}" 114 | 115 | - name: Validate SPC bin 116 | run: | 117 | chmod +x spc 118 | ./spc --version 119 | 120 | - id: cache-download 121 | uses: actions/cache@v4 122 | with: 123 | path: downloads 124 | key: php-${{ matrix.php-version }}-dependencies-for-tests 125 | 126 | # If there's no dependencies cache, fetch sources 127 | - name: "Download sources" 128 | env: 129 | GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} 130 | run: ./spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --ignore-cache-sources=php-src 131 | 132 | - name: "Build library: ${{ matrix.library }}" 133 | run: | 134 | SPC_USE_SUDO=yes ./spc doctor --auto-fix 135 | if [ "${{ env.OS }}" = "linux-x86_64" ]; then 136 | ./spc install-pkg upx 137 | UPX=--with-upx-pack 138 | elif [ "${{ env.OS }}" = "linux-aarch64" ]; then 139 | ./spc install-pkg upx 140 | UPX=--with-upx-pack 141 | fi 142 | ./spc build --build-cli --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts 143 | -------------------------------------------------------------------------------- /.github/workflows/ext-matrix-tests-php84.yml: -------------------------------------------------------------------------------- 1 | name: "Extension matrix tests PHP 8.4" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 1 * * 5" 7 | 8 | jobs: 9 | test: 10 | name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" 11 | runs-on: ${{ matrix.operating-system }} 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | extension: 16 | - amqp 17 | - apcu 18 | - bcmath 19 | - bz2 20 | - calendar 21 | - ctype 22 | - curl 23 | - dba 24 | - dom 25 | - ds 26 | - event 27 | - exif 28 | - filter 29 | - fileinfo 30 | - ftp 31 | - gd 32 | - gettext 33 | - gmp 34 | - iconv 35 | - igbinary 36 | - imagick 37 | - imap 38 | - intl 39 | - ldap 40 | - mbstring,mbregex 41 | - memcache 42 | - mysqli,mysqlnd,pdo_mysql 43 | - opcache 44 | - openssl 45 | - pcntl 46 | - password-argon2 47 | - pcntl 48 | - pdo 49 | - pgsql,pdo_pgsql 50 | - phar 51 | - posix 52 | - rar 53 | - protobuf 54 | - readline 55 | - redis 56 | - session 57 | - shmop 58 | - simdjson 59 | - simplexml,xml 60 | - snappy 61 | - soap 62 | - sockets 63 | - sodium 64 | - sqlite3,pdo_sqlite 65 | - sqlsrv 66 | - ssh2 67 | - swoole 68 | - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite 69 | - swow 70 | - sysvmsg,sysvsem,sysvshm 71 | - tidy 72 | - tokenizer 73 | - uuid 74 | - uv 75 | - xhprof 76 | - xlswriter 77 | - xmlwriter,xmlreader 78 | - xsl 79 | - yac 80 | - yaml 81 | - zip 82 | - zlib 83 | - zstd 84 | php-version: 85 | - "8.4" 86 | operating-system: 87 | - "ubuntu-latest" 88 | #- "macos-13" 89 | #- "debian-arm64-self-hosted" 90 | - "macos-14" 91 | 92 | steps: 93 | - name: "Checkout" 94 | uses: "actions/checkout@v4" 95 | 96 | - name: OS type 97 | id: os-type 98 | run: | 99 | OS="" 100 | if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then 101 | OS="linux-x86_64" 102 | elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then 103 | OS="macos-x86_64" 104 | elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then 105 | OS="linux-aarch64" 106 | elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then 107 | OS="macos-aarch64" 108 | fi 109 | echo "OS=$OS" >> $GITHUB_ENV 110 | 111 | - name: Download SPC bin artifact for self-hosted runners 112 | uses: dawidd6/action-download-artifact@v3 113 | with: 114 | repo: crazywhalecc/static-php-cli 115 | branch: main 116 | workflow: release-build.yml 117 | name: "spc-${{ env.OS }}" 118 | 119 | - name: Validate SPC bin 120 | run: | 121 | chmod +x spc 122 | ./spc --version 123 | 124 | - id: cache-download 125 | uses: actions/cache@v4 126 | with: 127 | path: downloads 128 | key: php-${{ matrix.php-version }}-dependencies-for-tests 129 | 130 | # If there's no dependencies cache, fetch sources 131 | - name: "Download sources" 132 | env: 133 | GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }} 134 | run: ./spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} 135 | 136 | - name: "Build library: ${{ matrix.library }}" 137 | run: | 138 | SPC_USE_SUDO=yes ./spc doctor --auto-fix 139 | if [ "${{ env.OS }}" = "linux-x86_64" ]; then 140 | ./spc install-pkg upx 141 | UPX=--with-upx-pack 142 | elif [ "${{ env.OS }}" = "linux-aarch64" ]; then 143 | ./spc install-pkg upx 144 | UPX=--with-upx-pack 145 | fi 146 | ./spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts 147 | -------------------------------------------------------------------------------- /.github/workflows/pack-libs.yml: -------------------------------------------------------------------------------- 1 | name: PHP Pack Lib 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 0 * * 5" 7 | release: 8 | types: 9 | - published 10 | pull_request: 11 | branches: [ "main" ] 12 | paths: 13 | - 'src/**' 14 | - 'config/**' 15 | - '.github/workflows/test-pack-lib.yml' 16 | - 'bin/**' 17 | 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | MUSL_VERSION: "1.2.5" 21 | GLIBC_VERSION: "2.17" 22 | 23 | jobs: 24 | build: 25 | name: "Pack ${{ matrix.lib }} for ${{ matrix.runner }}" 26 | runs-on: ${{ matrix.runner }} 27 | timeout-minutes: 240 28 | strategy: 29 | matrix: 30 | runner: 31 | - ubuntu-24.04 # x86_64 musl 32 | - ubuntu-22.04 # x86_64 glibc 33 | - ubuntu-24.04-arm # aarch64 musl 34 | - ubuntu-22.04-arm # aarch64 glibc 35 | - macos-13 36 | - windows-2019 37 | - macos-14 38 | lib: 39 | - zlib 40 | - pkg-config 41 | - bzip2 42 | - gmp 43 | - sqlite 44 | - liblz4 45 | - openssl 46 | - brotli 47 | - libargon2 48 | - libiconv 49 | - libavif 50 | - libpng 51 | - libtiff 52 | - icu 53 | - libcares 54 | - libevent 55 | - libsodium 56 | - libwebp 57 | - libyaml 58 | - ncurses 59 | - onig 60 | - readline 61 | - unixodbc 62 | - xz 63 | - grpc 64 | - libaom 65 | - libde265 66 | - libheif 67 | exclude: 68 | - { runner: "windows-2019", lib: "pkg-config" } 69 | - { runner: "windows-2019", lib: "gmp" } 70 | - { runner: "windows-2019", lib: "liblz4" } 71 | - { runner: "windows-2019", lib: "brotli" } 72 | - { runner: "windows-2019", lib: "libargon2" } 73 | - { runner: "windows-2019", lib: "libiconv" } 74 | - { runner: "windows-2019", lib: "libtiff" } 75 | - { runner: "windows-2019", lib: "icu" } 76 | - { runner: "windows-2019", lib: "libcares" } 77 | - { runner: "windows-2019", lib: "libevent" } 78 | - { runner: "windows-2019", lib: "libsodium" } 79 | - { runner: "windows-2019", lib: "ncurses" } 80 | - { runner: "windows-2019", lib: "readline" } 81 | - { runner: "windows-2019", lib: "unixodbc" } 82 | - { runner: "windows-2019", lib: "grpc" } 83 | - { runner: "windows-2019", lib: "libaom" } 84 | - { runner: "windows-2019", lib: "libde265" } 85 | - { runner: "windows-2019", lib: "libheif" } 86 | fail-fast: false 87 | steps: 88 | - name: "Process env string" 89 | id: process-env 90 | shell: bash 91 | run: | 92 | case "${{ matrix.runner }}" in 93 | ubuntu-24.04) 94 | echo "OS=linux-musl-${{ env.MUSL_VERSION }}" >> "$GITHUB_OUTPUT" 95 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 96 | echo "CMD=bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" 97 | ;; 98 | ubuntu-22.04) 99 | echo "OS=linux-glibc-${{ env.GLIBC_VERSION }}" >> "$GITHUB_OUTPUT" 100 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 101 | echo "CMD=bin/spc-gnu-docker" >> "$GITHUB_OUTPUT" 102 | ;; 103 | ubuntu-24.04-arm) 104 | echo "OS=linux-musl-${{ env.MUSL_VERSION }}" >> "$GITHUB_OUTPUT" 105 | echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" 106 | echo CMD="bin/spc-alpine-docker" >> "$GITHUB_OUTPUT" 107 | ;; 108 | ubuntu-22.04-arm) 109 | echo "OS=linux-glibc-${{ env.GLIBC_VERSION }}" >> "$GITHUB_OUTPUT" 110 | echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" 111 | echo "CMD=bin/spc-gnu-docker" >> "$GITHUB_OUTPUT" 112 | ;; 113 | windows-2019) 114 | echo "OS=windows" >> "$GITHUB_OUTPUT" 115 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 116 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 117 | ;; 118 | macos-13) 119 | echo "OS=darwin" >> "$GITHUB_OUTPUT" 120 | echo "ARCH=x86_64" >> "$GITHUB_OUTPUT" 121 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 122 | ;; 123 | macos-14) 124 | echo "OS=darwin" >> "$GITHUB_OUTPUT" 125 | echo "ARCH=aarch64" >> "$GITHUB_OUTPUT" 126 | echo "CMD=bin/spc" >> "$GITHUB_OUTPUT" 127 | ;; 128 | esac 129 | 130 | - name: "Checkout remote" 131 | if: github.repository != 'crazywhalecc/static-php-cli' 132 | uses: actions/checkout@v4 133 | with: 134 | repository: crazywhalecc/static-php-cli 135 | ref: main 136 | 137 | - name: "Setup PHP" 138 | if: matrix.runner != 'ubuntu-22.04' && matrix.runner != 'ubuntu-22.04-arm' 139 | uses: shivammathur/setup-php@v2 140 | with: 141 | php-version: 8.4 142 | tools: pecl, composer 143 | extensions: curl, openssl, mbstring, filter 144 | ini-values: memory_limit=-1 145 | 146 | - name: "Cache composer packages" 147 | id: composer-cache 148 | uses: actions/cache@v4 149 | with: 150 | path: vendor 151 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 152 | restore-keys: | 153 | ${{ runner.os }}-php 154 | 155 | # Cache downloaded source 156 | - id: cache-download 157 | uses: actions/cache@v4 158 | with: 159 | path: downloads 160 | key: pack-lib-dependencies 161 | 162 | - name: "Install Dependencies" 163 | if: matrix.runner != 'ubuntu-22.04' && matrix.runner != 'ubuntu-22.04-arm' 164 | run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist 165 | 166 | - run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix 167 | 168 | - run: ${{ steps.process-env.outputs.CMD }} download --for-libs="${{ matrix.lib }}" --debug --retry=5 --shallow-clone 169 | 170 | - name: "Download pre-built pkg-config for ${{ matrix.runner }}" 171 | if: matrix.runner != 'windows-2019' && matrix.lib != 'pkg-config' 172 | run: | 173 | ${{ steps.process-env.outputs.CMD }} download --for-libs="pkg-config" --debug --retry=5 --shallow-clone --prefer-pre-built 174 | ${{ steps.process-env.outputs.CMD }} build:libs pkg-config --debug 175 | 176 | - if: matrix.runner != 'windows-2019' || matrix.lib != 'pkg-config' 177 | run: ${{ steps.process-env.outputs.CMD }} dev:pack-lib --debug ${{ matrix.lib }} 178 | 179 | - name: "Upload packed lib (${{ matrix.lib }} for ${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }})" 180 | uses: actions/upload-artifact@v4 181 | with: 182 | path: dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz 183 | name: ${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }} 184 | 185 | - name: "Upload to current release event" 186 | if: github.repository == 'static-php/static-php-cli-hosted' && startsWith(github.ref, 'refs/tags/') 187 | uses: softprops/action-gh-release@v2 188 | with: 189 | files: dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz 190 | 191 | - name: "Update latest release of hosted repo" 192 | if: github.repository == 'static-php/static-php-cli-hosted' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') 193 | shell: bash 194 | run: | 195 | ref="$(gh release view --repo static-php/static-php-cli-hosted --json tagName --jq '.tagName')" 196 | gh release upload "$ref" "dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz" --repo static-php/static-php-cli-hosted --clobber 197 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # static-php-cli-hosted 2 | Self-Hosted [static-php-cli](https://github.com/crazywhalecc/static-php-cli) build action. 3 | 4 | ## Introduction 5 | 6 | This repository is used to automatically compile static-php-cli related content for different architectures and operating systems. 7 | 8 | ## List of Actions 9 | 10 | - [Archive download sources weekly](https://github.com/crazywhalecc/static-php-cli-hosted/blob/master/.github/workflows/download-cache.yml) 11 | - [Build PHP - Unix](https://github.com/crazywhalecc/static-php-cli-hosted/blob/master/.github/workflows/build-php-unix.yml) 12 | - [Build PHP - Windows](https://github.com/crazywhalecc/static-php-cli-hosted/blob/master/.github/workflows/build-php-windows.yml) 13 | - [Extension matrix tests (8.0)](https://github.com/static-php/static-php-cli-hosted/blob/master/.github/workflows/ext-matrix-tests-php80.yml) 14 | - [Extension matrix tests (8.4)](https://github.com/static-php/static-php-cli-hosted/blob/master/.github/workflows/ext-matrix-tests-php84.yml) 15 | - [Build pre-built packages](https://github.com/static-php/static-php-cli-hosted/blob/master/.github/workflows/pack-libs.yml) 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "crazywhalecc/static-php-cli-hosted" 3 | "require": { 4 | "crazywhalecc/static-php-cli": "dev-main" 5 | } 6 | } 7 | --------------------------------------------------------------------------------