Skip to content

Commit 725184a

Browse files
authored
Update and rename build-php-minimal.yml to build-php-unix.yml
1 parent 7987a6a commit 725184a

File tree

2 files changed

+158
-111
lines changed

2 files changed

+158
-111
lines changed

.github/workflows/build-php-minimal.yml

-111
This file was deleted.

.github/workflows/build-php-unix.yml

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Build Self-Hosted PHP Binary (Unix)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-release-artifacts:
8+
name: "Build ${{ matrix.php-version }}-${{ matrix.combination }} on ${{ matrix.runner }}"
9+
runs-on: ${{ matrix.runner }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
php-version:
14+
- "8.0"
15+
- "8.1"
16+
- "8.2"
17+
- "8.3"
18+
runner:
19+
- "ubuntu-latest"
20+
- "macos-13"
21+
- "ubuntu-20.04"
22+
- "macos-14"
23+
combination:
24+
- minimal
25+
- bulk
26+
- common
27+
steps:
28+
- name: "Process env string"
29+
id: process-env
30+
shell: bash
31+
run: |
32+
case "${{ martix.combination }}" in
33+
minimal)
34+
echo "EXTENSIONS=pcntl,posix,mbstring,tokenizer,phar" >> "$GITHUB_OUTPUT"
35+
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_MINIMAL }}" >> "$GITHUB_OUTPUT"
36+
;;
37+
common)
38+
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"
39+
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET }}" >> "$GITHUB_OUTPUT"
40+
;;
41+
bulk)
42+
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"
43+
echo "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_BULK }}" >> "$GITHUB_OUTPUT"
44+
;;
45+
esac
46+
47+
case "${{ matrix.runner }}" in
48+
ubuntu-latest)
49+
echo "OS=linux" >> "$GITHUB_OUTPUT"
50+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
51+
echo "CMD=bin/spc-alpine-docker" >> "$GITHUB_OUTPUT"
52+
;;
53+
ubuntu-20.04)
54+
echo "OS=linux" >> "$GITHUB_OUTPUT"
55+
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT"
56+
echo CMD="SPC_USE_ARCH=aarch64 bin/spc-alpine-docker" >> "$GITHUB_OUTPUT"
57+
;;
58+
windows-2019)
59+
echo "OS=windows" >> "$GITHUB_OUTPUT"
60+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
61+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
62+
;;
63+
macos-13)
64+
echo "OS=macos" >> "$GITHUB_OUTPUT"
65+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
66+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
67+
;;
68+
macos-14)
69+
echo "OS=macos" >> "$GITHUB_OUTPUT"
70+
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT"
71+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
72+
;;
73+
esac
74+
75+
- name: "Checkout remote"
76+
if: github.repository != 'crazywhalecc/static-php-cli'
77+
uses: actions/checkout@v4
78+
with:
79+
repository: crazywhalecc/static-php-cli
80+
ref: pre-built-libs
81+
82+
- name: "Setup PHP"
83+
if: matrix.runner != 'ubuntu-20.04'
84+
uses: shivammathur/setup-php@v2
85+
with:
86+
php-version: 8.2
87+
tools: pecl, composer
88+
extensions: curl, openssl, mbstring
89+
ini-values: memory_limit=-1
90+
91+
- name: "Cache composer packages"
92+
id: composer-cache
93+
uses: actions/cache@v4
94+
with:
95+
path: vendor
96+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
97+
restore-keys: |
98+
${{ runner.os }}-php
99+
100+
# Cache downloaded source
101+
- id: cache-download
102+
uses: actions/cache@v4
103+
with:
104+
path: downloads
105+
key: pack-lib-dependencies-${{ matrix.combination }}-${{ matrix.php-version }}
106+
107+
- name: "Install Dependencies"
108+
if: matrix.runner != 'ubuntu-20.04'
109+
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
110+
111+
- run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix
112+
113+
# If there's no dependencies cache, fetch sources
114+
- name: "Download sources"
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }}
117+
run: ${{ steps.process-env.outputs.CMD }} download --with-php=${{ matrix.php-version }} --for-extensions=${{ steps.process-env.outputs.EXTENSIONS }} --retry=5 --prefer-pre-built
118+
119+
- name: "Build library: ${{ matrix.library }}"
120+
run: |
121+
if [ "${{ steps.process-env.outputs.OS }}" = "linux" ]; then
122+
${{ steps.process-env.outputs.CMD }} install-pkg upx
123+
UPX=--with-upx-pack
124+
fi
125+
126+
${{ steps.process-env.outputs.CMD }} build --build-cli --build-micro --build-fpm ${{ steps.process-env.outputs.EXTENSIONS }} --debug $UPX
127+
128+
PHPVER=$(cat source/php-src/main/php_version.h | grep "PHP_VERSION " | awk -F\" '{print $2}')
129+
mkdir dist/
130+
tar -czf dist/php-$PHPVER-cli-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ php
131+
tar -czf dist/php-$PHPVER-micro-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ micro.sfx
132+
tar -czf dist/php-$PHPVER-fpm-${{ steps.process-env.outputs.OS }}.tar.gz -C buildroot/bin/ php-fpm
133+
if [ "${{ matrix.php-version }}" == "8.3" ] && [ "${{ matrix.runner }}" == "ubuntu-latest" ]; then
134+
cp -r buildroot/license dist/
135+
cp buildroot/build-extensions.json dist/
136+
cp buildroot/build-libraries.json dist/
137+
fi
138+
139+
- name: Deploy to Zhamao Server
140+
uses: easingthemes/ssh-deploy@main
141+
env:
142+
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
143+
ARGS: "-rltgoDzvO"
144+
SOURCE: "dist/"
145+
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
146+
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
147+
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
148+
TARGET: ${{ steps.process-env.outputs.DEPLOY_TARGET }}
149+
150+
- name: "Upload Artifact"
151+
uses: actions/upload-artifact@v4
152+
with:
153+
name: php-${{ matrix.php-version }}-${{ steps.process-env.outputs.OS }}
154+
path: |
155+
buildroot/bin/php
156+
buildroot/bin/php-fpm
157+
buildroot/bin/micro.sfx
158+
if-no-files-found: error

0 commit comments

Comments
 (0)