Skip to content

Commit 454472c

Browse files
committed
update
1 parent 67af0f9 commit 454472c

File tree

5 files changed

+218
-25
lines changed

5 files changed

+218
-25
lines changed

.github/workflows/build-alpine-builder-container.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ case $ARCH in
5050
PLATFORM="linux/mips64le"
5151
;;
5252
'loongarch64')
53-
PLATFORM="linux/mips64le"
53+
PLATFORM="linux/loongarch64"
5454
;;
5555
esac
5656

.github/workflows/build-debian-builder-container.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -exu
44
__DIR__=$(
@@ -18,7 +18,9 @@ cp -f ${__PROJECT__}/sapi/quickstart/linux/debian-init.sh .
1818
cp -f ${__PROJECT__}/sapi/quickstart/linux/extra/debian-php-init.sh .
1919

2020
cat > Dockerfile <<'EOF'
21-
FROM debian:unstable-20240110-slim
21+
ARG BASE_IMAGE=debian:12
22+
FROM ${BASE_IMAGE}
23+
# FROM debian:unstable
2224
2325
ENV DEBIAN_FRONTEND=noninteractive
2426
ENV TZ=Etc/UTC
@@ -43,12 +45,15 @@ EOF
4345

4446

4547
PLATFORM='linux/amd64'
46-
48+
BASE_IMAGE="debian:12"
4749
while [ $# -gt 0 ]; do
4850
case "$1" in
4951
--platform)
5052
PLATFORM="$2"
5153
;;
54+
--container-image)
55+
BASE_IMAGE="$2"
56+
;;
5257
--*)
5358
echo "Illegal option $1"
5459
;;
@@ -59,8 +64,8 @@ done
5964

6065

6166
IMAGE='swoole-cli-builder:latest'
62-
docker buildx build -t ${IMAGE} -f ./Dockerfile . --platform ${PLATFORM}
63-
67+
docker buildx build -t ${IMAGE} -f ./Dockerfile . --platform ${PLATFORM} --build-arg BASE_IMAGE="${BASE_IMAGE}"
68+
docker images
6469
docker save -o "swoole-cli-builder-image.tar" ${IMAGE}
6570

6671

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: build-php-cli-linux-loongarch
2+
3+
on: [ push, pull_request ]
4+
5+
env:
6+
BUILD_PHP_VERSION: 8.2.13
7+
8+
jobs:
9+
linux-loongarch:
10+
if: 0
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Prepare Source Code
15+
run: |
16+
echo $PATH
17+
env
18+
docker info
19+
id -u
20+
id -g
21+
who
22+
cat /etc/os-release
23+
hostnamectl
24+
uname -s
25+
uname -m
26+
uname -r
27+
export IPV6=$(ip -6 address show | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p')
28+
export IPV4=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1 | sed -n '1p')
29+
echo $IPV4
30+
echo $IPV6
31+
echo "X_IPV6=${IPV6}" >> $GITHUB_ENV
32+
echo "X_IPV4=${IPV4}" >> $GITHUB_ENV
33+
34+
echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV
35+
36+
# git submodule update --init
37+
38+
sudo mkdir -p /usr/local/swoole-cli
39+
uid=$(id -u) && gid=$(id -g) && sudo chown -R ${uid}:${gid} /usr/local/swoole-cli
40+
41+
mkdir -p ${{ github.workspace }}/var/build-github-action-container/
42+
43+
- name: Cache PHP Vendor
44+
uses: actions/cache@v3
45+
id: php-vendor-cache
46+
with:
47+
path: ${{ github.workspace }}/vendor
48+
key: ${{ runner.os }}-loongarch-php-vendor
49+
50+
- name: Cache Dependency Source Code Tarball
51+
uses: actions/cache@v4
52+
id: pool-cache
53+
with:
54+
path: ${{ github.workspace }}/pool/
55+
key: source-code-tarball-pool
56+
57+
- name: Cache all-library
58+
uses: actions/cache@v4
59+
id: all-library-cache
60+
with:
61+
path: /usr/local/swoole-cli
62+
key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-loongarch-all-library
63+
64+
- name: Cache swoole-cli-builder-image
65+
uses: actions/cache@v4
66+
id: swoole-cli-builder-image-loongarch-cache
67+
with:
68+
path: ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar
69+
key: ${{ runner.os }}-loongarch-swoole-cli-builder-image
70+
71+
- name: Prepare Libraries and Extensions
72+
run: |
73+
set -x
74+
mkdir -p pool/lib
75+
mkdir -p pool/ext
76+
77+
CACHE_NUM=$(ls -A pool/lib/ | wc -l)
78+
LIB_NUM=$(ls -A sapi/src/builder/library/ | wc -l)
79+
echo `expr $LIB_NUM - $CACHE_NUM`
80+
81+
if test $CACHE_NUM -eq 0 ; then
82+
bash sapi/download-box/download-box-get-archive-from-container.sh
83+
fi
84+
85+
ls -A pool/lib/
86+
ls -A /usr/local/swoole-cli/
87+
- name: Set up QEMU
88+
uses: docker://loongarch/qemu-user-static:latest # Replace with your image
89+
with:
90+
arch: loongarch64
91+
qemu-binary: qemu-loongarch64 # Or your QEMU binary
92+
93+
- name: Run LoongArch command
94+
run: |
95+
uname -a
96+
uname -s
97+
uname -m
98+
99+
100+
- name: Prepare swoole-cli-builder-image
101+
run: |
102+
if [ -f ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar ] ; then
103+
docker load -i ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar
104+
else
105+
bash .github/workflows/build-debian-builder-container.sh --platform "linux/loongarch64"
106+
fi
107+
108+
- name: prepare pre-built library
109+
if: 1
110+
uses: addnab/docker-run-action@v3
111+
with:
112+
image: swoole-cli-builder:latest
113+
options: -v ${{ github.workspace }}:/work -w /work -v /usr/local/swoole-cli/:/usr/local/swoole-cli/
114+
run: |
115+
for i in `ls /usr/local/swoole-cli/`
116+
do
117+
echo $i
118+
done
119+
uname -a
120+
uname -s
121+
uname -m
122+
apt install -y php-dev php-cli
123+
124+
125+
- name: Build
126+
if: 1
127+
uses: addnab/docker-run-action@v3
128+
with:
129+
image: swoole-cli-builder:latest
130+
options: -v ${{ github.workspace }}:/work -w /work -e BUILD_PHP_VERSION=${{ env.BUILD_PHP_VERSION }} -v /usr/local/swoole-cli:/usr/local/swoole-cli
131+
run: |
132+
set -eux
133+
uname -m
134+
if [ ! -f bin/runtime/php ] ; then
135+
bash setup-php-runtime.sh
136+
fi
137+
138+
# export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer
139+
# alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem"
140+
141+
sh sapi/quickstart/linux/alpine-init.sh
142+
composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev
143+
composer dump-autoload --optimize --profile --no-dev
144+
145+
php prepare.php --with-override-default-enabled-ext=1 --with-php-version=8.3.4
146+
147+
bash make-install-deps.sh
148+
149+
bash make.sh all-library
150+
151+
bash make.sh config
152+
bash make.sh build
153+
bash make.sh archive
154+
155+
- name: Show Build Result
156+
if: 1
157+
uses: addnab/docker-run-action@v3
158+
with:
159+
image: swoole-cli-builder:latest
160+
options: -v ${{ github.workspace }}:/work -w /work
161+
run: |
162+
./thirdparty/php-src/sapi/cli/php -v
163+
./thirdparty/php-src/sapi/cli/php -m
164+
BUILD_PHP_VERSION=$(./thirdparty/php-src/sapi/cli/php -v | head -n 1 | awk '{print $2}')
165+
file ./bin/php-${BUILD_PHP_VERSION}/bin/php
166+
readelf -h ./bin/php-${BUILD_PHP_VERSION}/bin/php
167+
APP_VERSION=$(./bin/php-${BUILD_PHP_VERSION}/bin/php -v | head -n 1 | awk '{print $2}')
168+
echo ${APP_VERSION}
169+
echo ${APP_VERSION} > APP_VERSION
170+
./bin/php-${BUILD_PHP_VERSION}/bin/php -r "echo PHP_VERSION;"
171+
172+
- name: get app version
173+
if: 1
174+
run: |
175+
APP_VERSION=$(cat ./APP_VERSION)
176+
echo $APP_VERSION
177+
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
178+
echo "BUILD_PHP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
179+
180+
- name: production artifacts debug
181+
if: 0
182+
uses: actions/upload-artifact@v4
183+
with:
184+
name: php-cli-v${{ env.APP_VERSION }}-linux-mips64le-debug
185+
retention-days: 90
186+
path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php
187+
188+
- name: production artifacts
189+
if: 0
190+
uses: actions/upload-artifact@v4
191+
with:
192+
name: php-cli-v${{ env.APP_VERSION }}-linux-mips64le
193+
retention-days: 90
194+
path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/dist/php
195+
196+
- name: gh release
197+
uses: softprops/action-gh-release@v2
198+
if: 0 && startsWith(github.ref, 'refs/tags/')
199+
with:
200+
files: |
201+
php-cli-v${{ env.APP_VERSION }}-linux-mips64le.tar.xz
202+
php-cli-v${{ env.APP_VERSION }}-linux-mips64le-debug.tar.xz

.github/workflows/linux-mips64le.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ jobs:
7373
set -x
7474
mkdir -p pool/lib
7575
mkdir -p pool/ext
76-
mkdir -p bin/runtime
7776
7877
CACHE_NUM=$(ls -A pool/lib/ | wc -l)
7978
LIB_NUM=$(ls -A sapi/src/builder/library/ | wc -l)

.github/workflows/linux-riscv64.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,8 @@ jobs:
6363
set -x
6464
mkdir -p pool/lib
6565
mkdir -p pool/ext
66-
mkdir -p bin/runtime
6766
68-
CACHE_NUM=$(ls -A pool/lib/ | wc -l)
69-
LIB_NUM=$(ls -A sapi/src/builder/library/ | wc -l)
70-
echo `expr $LIB_NUM - $CACHE_NUM`
71-
72-
if test $CACHE_NUM -eq 0 ; then
73-
bash sapi/download-box/download-box-get-archive-from-container.sh
74-
fi
67+
bash sapi/download-box/download-box-get-archive-from-container.sh
7568
7669
ls -A pool/lib/
7770
ls -A /usr/local/swoole-cli/
@@ -95,7 +88,7 @@ jobs:
9588
if [ -f ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar ] ; then
9689
docker load -i ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar
9790
else
98-
bash .github/workflows/build-debian-builder-container.sh --platform "linux/riscv64"
91+
bash .github/workflows/build-debian-builder-container.sh --platform "linux/riscv64" --container-image "debian:unstable"
9992
fi
10093
10194
- name: prepare pre-built library
@@ -123,16 +116,12 @@ jobs:
123116
run: |
124117
set -eux
125118
uname -m
126-
if [ ! -f bin/runtime/php ] ; then
119+
if [ ! -f runtime/php/php ] ; then
127120
bash setup-php-runtime.sh
128121
fi
129122
130-
# export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer
131-
# alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem"
132-
133-
# sed -i 's/mirrors.tuna.tsinghua.edu.cn/dl-cdn.alpinelinux.org/g' /etc/apk/repositories
134-
# sed -i 's/mirrors.ustc.edu.cn/dl-cdn.alpinelinux.org/g' /etc/apk/repositories
135-
# bash sapi/quickstart/mark-install-library-cached.sh
123+
export PATH=/work/runtime/php/:$PATH # 容器已经内置 php 和 composer
124+
alias php="php -d curl.cainfo=/work/runtime/php/cacert.pem -d openssl.cafile=/work/runtime/php/cacert.pem"
136125
137126
sh sapi/quickstart/linux/alpine-init.sh
138127
composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev
@@ -143,7 +132,6 @@ jobs:
143132
bash make-install-deps.sh
144133
145134
bash make.sh all-library
146-
# rm -rf /work/thirdparty/php-src/ext/pcre/
147135
148136
bash make.sh config
149137
bash make.sh build
@@ -197,4 +185,3 @@ jobs:
197185
files: |
198186
php-cli-v${{ env.APP_VERSION }}-linux-riscv64.tar.xz
199187
php-cli-v${{ env.APP_VERSION }}-linux-riscv64-debug.tar.xz
200-

0 commit comments

Comments
 (0)