merge code #8910
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-linux-x86_64 | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
build_latest_swoole_or_swow: | |
required: true | |
description: "定制构建选项: 构建最新版的 swoole 或者 swow (此二者扩展不能同时启用)" | |
default: ' ' | |
type: choice | |
options: | |
- ' ' | |
- '-swoole +swoole_latest' | |
- '-swoole +swow_latest' | |
- '-swoole +swow' | |
php_version: | |
required: true | |
description: "定制构建选项: 指定 PHP 版本(版本号大于等于8.1)" | |
default: '--with-php-version=8.2.27' | |
type: choice | |
options: | |
- '--with-php-version=8.1.31' | |
- '--with-php-version=8.2.27' | |
- '--with-php-version=8.3.15' | |
build_type: | |
required: true | |
description: "定制构建选项: 指定构建类型" | |
default: '--with-build-type=release' | |
type: choice | |
options: | |
- '--with-build-type=release' | |
- '--with-build-type=dev' | |
build_options: | |
required: false | |
description: "定制构建选项: 请查看 docs/options.md" | |
default: ' ' | |
type: string | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
BUILD_PHP_VERSION: 8.2.27 | |
jobs: | |
linux-x86_64: | |
if: 0 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-version: | |
- "8.2.27" | |
- "8.1.31" | |
- "8.3.15" | |
- "8.4.2" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Show Environment Info | |
run: | | |
echo "${{ github.event.head_commit.message }}" | |
echo "${{ github.event.workflow_run.head_commit.message }}" | |
echo $PATH | |
env | |
docker info | |
id -u | |
id -g | |
who | |
cat /etc/os-release | |
hostnamectl | |
uname -s | |
uname -m | |
uname -r | |
# echo "BUILD_PHP_VERSION=8.2.4" >> "$GITHUB_ENV" | |
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c | |
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l | |
cat /proc/cpuinfo | grep "cpu cores" | uniq | |
cat /proc/cpuinfo| grep "processor"| wc -l | |
lscpu | |
export IPV6=$(ip -6 address show | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p') | |
export IPV4=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1 | sed -n '1p') | |
echo $IPV4 | |
echo $IPV6 | |
echo "X_IPV6=${IPV6}" >> $GITHUB_ENV | |
echo "X_IPV4=${IPV4}" >> $GITHUB_ENV | |
sudo apt install -y jq curl | |
curl https://detect-ip.xiaoshuogeng.com/ip/json | jq | |
echo ${{ env.BRANCH_NAME }} | |
echo ${{ github.actor }} | |
echo ${{ github.repository }} | |
echo ${{ github.repository_owner }} | |
echo ${{ github.head_ref }} | |
echo ${{ github.ref_name }} | |
- name: Prepare Build Environment | |
run: | | |
# git submodule update --init | |
echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV | |
sudo mkdir -p /usr/local/swoole-cli | |
uid=$(id -u) && gid=$(id -g) && sudo chown -R ${uid}:${gid} /usr/local/swoole-cli | |
mkdir -p ${{ github.workspace }}/var/build-github-action-container/ | |
- name: Cache PHP Runtime | |
uses: actions/cache@v4 | |
id: php-runtime-cache | |
with: | |
path: ${{ github.workspace }}/bin/runtime | |
key: ${{ runner.os }}-x86_64-php-runtime | |
- name: Cache PHP Vendor | |
uses: actions/cache@v4 | |
id: php-vendor-cache | |
with: | |
path: ${{ github.workspace }}/vendor | |
key: ${{ runner.os }}-x86_64-php-vendor | |
- name: Cache Dependency Source Code Tarball | |
uses: actions/cache@v4 | |
id: pool-cache | |
with: | |
path: ${{ github.workspace }}/pool/ | |
key: source-code-tarball-pool | |
- name: Cache all-library | |
uses: actions/cache@v4 | |
id: all-library-cache | |
with: | |
path: /usr/local/swoole-cli | |
key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-x86_64-all-library | |
- name: Cache swoole-cli-builder-image | |
uses: actions/cache@v4 | |
id: swoole-cli-builder-image-cache | |
with: | |
path: ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar | |
key: ${{ runner.os }}-x86_64-swoole-cli-builder-image | |
- name: Prepare swoole-cli-builder-image | |
run: | | |
if [ -f ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar ] ; then | |
docker load -i ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar | |
else | |
bash .github/workflows/build-alpine-builder-container.sh | |
fi | |
- name: Prepare Runtime and Libraries and Extensions | |
run: | | |
set -x | |
mkdir -p pool/lib | |
mkdir -p pool/ext | |
mkdir -p bin/runtime | |
if [ ! -f bin/runtime/php ] ; then | |
bash setup-php-runtime.sh | |
fi | |
CACHE_NUM=$(ls -A pool/lib/ | wc -l) | |
LIB_NUM=$(ls -A sapi/src/builder/library/ | wc -l) | |
echo `expr $LIB_NUM - $CACHE_NUM` | |
if test $(ls -A /usr/local/swoole-cli/ | wc -l) -eq 0 ; then | |
TAG=all-dependencies-alpine-3.17-php8-v1.0.0-x86_64-20231113T125520Z | |
IMAGE="docker.io/jingjingxyk/build-swoole-cli:${TAG}" | |
container_id=$(docker create $IMAGE) # returns container ID | |
docker cp $container_id:/usr/local/swoole-cli/ /usr/local/ | |
docker rm $container_id | |
fi | |
bash sapi/download-box/download-box-get-archive-from-server.sh | |
ls -A pool/lib/ | |
ls -A /usr/local/swoole-cli/ | |
- name: Build | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: swoole-cli-builder:latest | |
options: -v ${{ github.workspace }}:/work -w /work -e BUILD_PHP_VERSION=${{ env.BUILD_PHP_VERSION }} -v /usr/local/swoole-cli:/usr/local/swoole-cli | |
run: | | |
set -eux | |
uname -m | |
export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer | |
alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem" | |
# bash sapi/quickstart/mark-install-library-cached.sh | |
sh sapi/quickstart/linux/alpine-init.sh | |
composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev | |
composer dump-autoload --optimize --profile --no-dev | |
php prepare.php -ffmpeg +coturn --with-build-type=release ${{ inputs.build_type }} ${{ inputs.build_options }} --with-c-compiler=clang | |
bash make-install-deps.sh | |
sed -i.backup "s/-ldl/ /g" /usr/local/swoole-cli/openssl/lib/pkgconfig/libcrypto.pc | |
bash ./make.sh all-library | |
bash ./make.sh config | |
# bash ./make.sh build | |
# bash ./make.sh archive | |
- name: Show Build Result | |
run: | | |
./thirdparty/php-src/sapi/cli/php -v | |
./thirdparty/php-src/sapi/cli/php -m | |
./thirdparty/php-src/sapi/cli/php --ri gd | |
./thirdparty/php-src/sapi/cli/php --ri swoole | |
./thirdparty/php-src/sapi/cli/php --ri pgsql | |
./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php -v | |
file ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php | |
readelf -h ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php | |
APP_VERSION=$(./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php -v | head -n 1 | awk '{print $2}') | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php -r "echo PHP_VERSION;" | |
./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php ./vendor/bin/phpunit ./sapi/src/UnitTest/MainTest.php --list-tests | |
./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php ./vendor/bin/phpunit ./sapi/src/UnitTest/MainTest.php | |
# ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php ./vendor/bin/phpunit ./sapi/src/UnitTest/SwoolePGSQLTest.php | |
- name: production artifacts debug | |
uses: actions/upload-artifact@v4 | |
with: | |
name: php-cli-v${{ env.APP_VERSION }}-linux-x64-debug | |
retention-days: 90 | |
path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php | |
- name: production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: php-cli-v${{ env.APP_VERSION }}-linux-x64 | |
retention-days: 90 | |
path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/dist/php | |
- name: gh release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
php-cli-v${{ env.APP_VERSION }}-linux-x64.tar.xz | |
php-cli-v${{ env.APP_VERSION }}-linux-x64-debug.tar.xz | |
- name: upload artifacts to cloud object storage | |
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} | |
env: | |
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }} | |
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }} | |
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }} | |
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }} | |
run: | | |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-linux-x64.tar.xz | |