Skip to content

Commit 55f6e11

Browse files
authored
更新配置运行时脚本 (#946)
* 更新配置运行时脚本 * install docker with script * update README.md * update build-release-example.sh * update run-swoole-cli-builder-container.sh
1 parent 27382f6 commit 55f6e11

15 files changed

+127
-130
lines changed

.github/workflows/auto-cache-pool-tarball.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,14 @@ jobs:
7171
set -x
7272
mkdir -p pool/lib
7373
mkdir -p pool/ext
74-
mkdir -p bin/runtime
75-
if [ ! -f bin/runtime/php ] ; then
74+
mkdir -p runtime/
75+
if [ ! -f runtime/php ] ; then
7676
bash setup-php-runtime.sh
7777
fi
7878
79-
ls -A pool/lib/
8079
WORK_DIR=${{ github.workspace }}
81-
uname -m
82-
export PATH=${WORK_DIR}/bin/runtime:$PATH
83-
alias php="php -d curl.cainfo=${WORK_DIR}/bin/runtime/cacert.pem -d openssl.cafile=${WORK_DIR}/bin/runtime/cacert.pem"
80+
export PATH=${WORK_DIR}/runtime/:$PATH
81+
alias php="php -d curl.cainfo=${WORK_DIR}/runtime/cacert.pem -d openssl.cafile=${WORK_DIR}/runtime/cacert.pem"
8482
8583
composer install --no-interaction --no-autoloader --no-scripts --profile
8684
composer dump-autoload --optimize --profile

.github/workflows/linux-aarch64.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/cache@v4
4949
id: php-runtime-cache-aarch64
5050
with:
51-
path: ${{ github.workspace }}/bin/runtime
51+
path: ${{ github.workspace }}/runtime
5252
key: ${{ runner.os }}-aarch64-php-runtime
5353

5454
- name: Cache PHP Vendor
@@ -92,8 +92,9 @@ jobs:
9292
set -x
9393
mkdir -p pool/lib
9494
mkdir -p pool/ext
95-
mkdir -p bin/runtime
96-
if [ ! -f bin/runtime/php ] ; then
95+
mkdir -p bin/
96+
mkdir -p runtime/
97+
if [ ! -f runtime/php ] ; then
9798
bash setup-php-runtime.sh
9899
fi
99100
bash sapi/download-box/download-box-get-archive-from-server.sh
@@ -108,8 +109,8 @@ jobs:
108109
run: |
109110
set -eux
110111
uname -m
111-
export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer
112-
alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem"
112+
export PATH=/work/runtime:$PATH # 容器已经内置 php 和 composer
113+
alias php="php -d curl.cainfo=/work/runtime/cacert.pem -d openssl.cafile=/work/runtime/cacert.pem"
113114
114115
sh sapi/quickstart/linux/alpine-init.sh
115116
composer install --no-interaction --no-autoloader --no-scripts --profile

.github/workflows/linux-x86_64.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/cache@v4
4949
id: php-runtime-cache-x86_64
5050
with:
51-
path: ${{ github.workspace }}/bin/runtime
51+
path: ${{ github.workspace }}/runtime
5252
key: ${{ runner.os }}-x86_64-php-runtime
5353

5454
- name: Cache PHP Vendor
@@ -92,8 +92,9 @@ jobs:
9292
set -x
9393
mkdir -p pool/lib
9494
mkdir -p pool/ext
95-
mkdir -p bin/runtime
96-
if [ ! -f bin/runtime/php ] ; then
95+
mkdir -p bin/
96+
mkdir -p runtime/
97+
if [ ! -f runtime/php ] ; then
9798
bash setup-php-runtime.sh
9899
fi
99100
bash sapi/download-box/download-box-get-archive-from-server.sh
@@ -108,8 +109,8 @@ jobs:
108109
run: |
109110
set -eux
110111
uname -m
111-
export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer
112-
alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem"
112+
export PATH=/work/runtime:$PATH # 容器已经内置 php 和 composer
113+
alias php="php -d curl.cainfo=/work/runtime/cacert.pem -d openssl.cafile=/work/runtime/cacert.pem"
113114
114115
sh sapi/quickstart/linux/alpine-init.sh
115116
composer install --no-interaction --no-autoloader --no-scripts --profile

.github/workflows/macos-aarch64.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/cache@v4
5959
id: php-runtime-cache
6060
with:
61-
path: ${{ github.workspace }}/bin/runtime
61+
path: ${{ github.workspace }}/runtime
6262
key: ${{ runner.os }}-aarch64-php-runtime
6363

6464
- name: Cache PHP Vendor
@@ -87,18 +87,19 @@ jobs:
8787
set -x
8888
mkdir -p pool/lib
8989
mkdir -p pool/ext
90-
mkdir -p bin/runtime
91-
if [ ! -f bin/runtime/php ] ; then
92-
bash sapi/quickstart/setup-php-runtime.sh
90+
mkdir -p bin/
91+
mkdir -p runtime/
92+
if [ ! -f runtime/php ] ; then
93+
bash setup-php-runtime.sh
9394
fi
9495
bash sapi/download-box/download-box-get-archive-from-server.sh
9596
ls -A pool/lib/
9697
ls -A /usr/local/swoole-cli/
9798
9899
- name: prepare
99100
run: |
100-
export PATH=${{ github.workspace }}/bin/runtime:$PATH
101-
alias php="php -d curl.cainfo=${{ github.workspace }}/bin/runtime/cacert.pem -d openssl.cafile=${{ github.workspace }}/bin/runtime/cacert.pem"
101+
export PATH=${{ github.workspace }}/runtime:$PATH
102+
alias php="php -d curl.cainfo=${{ github.workspace }}/runtime/cacert.pem -d openssl.cafile=${{ github.workspace }}/runtime/cacert.pem"
102103
103104
composer install --no-interaction --no-autoloader --no-scripts --profile
104105
composer dump-autoload --optimize --profile
@@ -107,7 +108,7 @@ jobs:
107108
108109
- name: Build
109110
run: |
110-
export PATH=${{ github.workspace }}/bin/runtime:$PATH
111+
export PATH=${{ github.workspace }}/runtime:$PATH
111112
112113
bash ./make.sh all-library
113114

.github/workflows/macos-x86_64.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/cache@v4
5959
id: php-runtime-cache
6060
with:
61-
path: ${{ github.workspace }}/bin/runtime
61+
path: ${{ github.workspace }}/runtime
6262
key: ${{ runner.os }}-x86_64-php-runtime
6363

6464
- name: Cache PHP Vendor
@@ -87,18 +87,19 @@ jobs:
8787
set -x
8888
mkdir -p pool/lib
8989
mkdir -p pool/ext
90-
mkdir -p bin/runtime
91-
if [ ! -f bin/runtime/php ] ; then
92-
bash sapi/quickstart/setup-php-runtime.sh
90+
mkdir -p bin/
91+
mkdir -p runtime/
92+
if [ ! -f runtime/php ] ; then
93+
bash setup-php-runtime.sh
9394
fi
9495
bash sapi/download-box/download-box-get-archive-from-server.sh
9596
ls -A pool/lib/
9697
ls -A /usr/local/swoole-cli/
9798
9899
- name: prepare
99100
run: |
100-
export PATH=${{ github.workspace }}/bin/runtime:$PATH
101-
alias php="php -d curl.cainfo=${{ github.workspace }}/bin/runtime/cacert.pem -d openssl.cafile=${{ github.workspace }}/bin/runtime/cacert.pem"
101+
export PATH=${{ github.workspace }}/runtime:$PATH
102+
alias php="php -d curl.cainfo=${{ github.workspace }}/runtime/cacert.pem -d openssl.cafile=${{ github.workspace }}/runtime/cacert.pem"
102103
103104
composer install --no-interaction --no-autoloader --no-scripts --profile
104105
composer dump-autoload --optimize --profile
@@ -107,7 +108,7 @@ jobs:
107108
108109
- name: Build
109110
run: |
110-
export PATH=${{ github.workspace }}/bin/runtime:$PATH
111+
export PATH=${{ github.workspace }}/runtime:$PATH
111112
112113
bash ./make.sh all-library
113114

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,5 @@ Makefile.backup
324324
ldflags.log
325325
cppflags.log
326326
libs.log
327-
327+
/runtime
328+
!/runtime/.gitkeep

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ bash setup-php-runtime.sh
8484
# 来自 https://www.swoole.com/download
8585
bash setup-php-runtime.sh --mirror china
8686

87+
# 使用swoole-cli
88+
# shell脚本中启用别名扩展功能‌
89+
shopt -s expand_aliases
90+
__DIR__=$(pwd)
91+
export PATH="${__DIR__}/runtime:$PATH"
92+
ln -sf ${__DIR__}/runtime/swoole-cli ${__DIR__}/runtime/php
93+
alias php="php -d curl.cainfo=${__DIR__}/runtime/cacert.pem -d openssl.cafile=${__DIR__}/runtime/cacert.pem"
94+
which php
95+
php -v
96+
8797
```
8898

8999
## 生成构建脚本

build-release-example.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ __DIR__=$(
55
pwd
66
)
77
__PROJECT__=${__DIR__}
8-
8+
shopt -s expand_aliases
99
if [ ! -f ${__DIR__}/prepare.php ]; then
1010
echo 'no found prepare.php'
1111
exit 0
@@ -137,16 +137,16 @@ if [ "$OS" = 'macos' ]; then
137137

138138
fi
139139

140-
if [ ! -f "${__PROJECT__}/bin/runtime/php" ]; then
140+
if [ ! -f "${__PROJECT__}/runtime/php" ]; then
141141
if [ "$MIRROR" = 'china' ]; then
142-
bash sapi/quickstart/setup-php-runtime.sh --mirror china
142+
bash ${__PROJECT__}/setup-php-runtime.sh --mirror china
143143
else
144-
bash sapi/quickstart/setup-php-runtime.sh
144+
bash ${__PROJECT__}/setup-php-runtime.sh
145145
fi
146146
fi
147147

148-
export PATH="${__PROJECT__}/bin/runtime:$PATH"
149-
alias php="php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem"
148+
export PATH="${__PROJECT__}/runtime:$PATH"
149+
alias php="php -d curl.cainfo=${__PROJECT__}/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/runtime/cacert.pem"
150150

151151
php -v
152152

@@ -190,7 +190,7 @@ if [ ${IN_DOCKER} -eq 1 ]; then
190190
{
191191
# 容器中
192192

193-
php prepare.php +inotify ${OPTIONS}
193+
php prepare.php ${OPTIONS}
194194

195195
}
196196
else

runtime/.gitkeep

Whitespace-only changes.

sapi/quickstart/linux/install-docker.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ __DIR__=$(
55
cd "$(dirname "$0")"
66
pwd
77
)
8-
__PROJECT__=$(
9-
cd ${__DIR__}/../../../
10-
pwd
11-
)
12-
cd ${__DIR__}
8+
9+
if [ -f "${__DIR__}/../../../prepare.php" ]; then
10+
__PROJECT__=$(
11+
cd ${__DIR__}/../../../
12+
pwd
13+
)
14+
else
15+
__PROJECT__=${__DIR__}
16+
fi
17+
18+
cd ${__PROJECT__}
1319

1420
mkdir -p ${__PROJECT__}/var
1521

0 commit comments

Comments
 (0)