diff --git a/.github/workflows/artifact-hash.yml b/.github/workflows/artifact-hash.yml index 874f1c7e5a..05c87ee1c8 100644 --- a/.github/workflows/artifact-hash.yml +++ b/.github/workflows/artifact-hash.yml @@ -6,12 +6,17 @@ on: version: required: true description: "发版 版本号 tag" - default: 'v5.1.6.0' + default: 'v6.0.0.0' type: string + enable_upload_cloud_object_storage: + required: false + type: boolean + description: "上传到云对象存储 (默认不需要上传)" jobs: generate-artifact-hash: runs-on: ubuntu-latest + if: 0 steps: - uses: actions/checkout@v4 - name: Show Release File Hash @@ -25,3 +30,14 @@ jobs: retention-days: 90 path: | ${{ inputs.version }}-sha256sum + + - name: upload artifacts to cloud object storage + if: ${{ (github.repository == 'swoole/swoole-cli') && (inputs.enable_upload_cloud_object_storage == true) }} + 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-all --swoole-cli-version ${{ inputs.version }} + diff --git a/.github/workflows/auto-cache-pool-tarball.yml b/.github/workflows/auto-cache-pool-tarball.yml index 2788d34c26..ab0ed3d33b 100644 --- a/.github/workflows/auto-cache-pool-tarball.yml +++ b/.github/workflows/auto-cache-pool-tarball.yml @@ -61,7 +61,7 @@ jobs: key: source-code-tarball-pool - name: Clean Source Code Tarball Cache On Release - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} run: rm -rf ${{ github.workspace }}/pool/* @@ -100,7 +100,6 @@ jobs: ls -A pool/ext/ - name: production artifacts - if: 1 uses: actions/upload-artifact@v4 with: name: all-deps @@ -111,7 +110,7 @@ jobs: - name: gh release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} with: files: | all-deps.zip diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index e1bab8d1a2..c863e3a3b7 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -183,3 +183,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: swoole-cli-v${{ env.APP_VERSION }}-linux-arm64.tar.xz + + - name: upload artifacts to cloud object storage + if: ${{ (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-arm64.tar.xz diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index 6e316ddcc4..cca0c9be2e 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -165,3 +165,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: swoole-cli-v${{ env.APP_VERSION }}-linux-x64.tar.xz + + - name: upload artifacts to cloud object storage + if: ${{ (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 diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 141c41ab22..546fc4ea43 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -148,3 +148,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: swoole-cli-v${{ env.APP_VERSION }}-macos-arm64.tar.xz + + - name: upload artifacts to cloud object storage + if: ${{ (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 }}-macos-arm64.tar.xz diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 89742b5cba..b0b76dca45 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -148,3 +148,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: swoole-cli-v${{ env.APP_VERSION }}-macos-x64.tar.xz + + - name: upload artifacts to cloud object storage + if: ${{ (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 }}-macos-x64.tar.xz diff --git a/.github/workflows/runner-images.md b/.github/workflows/runner-images.md new file mode 100644 index 0000000000..cd909a2940 --- /dev/null +++ b/.github/workflows/runner-images.md @@ -0,0 +1,5 @@ +[runner-images](https://github.com/actions/runner-images/tree/main/images) + +[available-images](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) + +[choosing-github-hosted-runners](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners) diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index 748fd00269..213bda6ff8 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -5,12 +5,23 @@ on: [ push, pull_request ] jobs: windows-cygwin: if: 1 - runs-on: windows-latest + runs-on: windows-2022 steps: + - name: Show Environment Info + shell: cmd + run: | + ver + wmic cpu get name, caption, maxclockspeed, status + systeminfo + systeminfo | findstr /B /C:"OS Name" /C:"OS Version" + systeminfo | findstr /B /C:"Manufacturer" /C:"Product" /C:"Version" + set + - name: Prepare git run: | git config --global core.autocrlf false git config --global core.eol lf + git config --global core.ignorecase false ipconfig - uses: actions/checkout@v4 @@ -36,25 +47,34 @@ jobs: - name: Install Cygwin uses: cygwin/cygwin-install-action@v2 + with: + site: https://mirrors.kernel.org/sourceware/cygwin/ # with: # platform: x64 # packages: make wget tar libtool re2c bison gcc-g++ autoconf automake openssl libpcre2-devel libssl-devel libcurl-devel libxml2-devel libxslt-devel libgmp-devel ImageMagick libpng-devel libjpeg-devel libfreetype-devel libwebp-devel libsqlite3-devel zlib-devel libbz2-devel liblz4-devel liblzma-devel libzip-devel libicu-devel libonig-devel libcares-devel libsodium-devel libyaml-devel libMagick-devel libzstd-devel libbrotli-devel libreadline-devel libintl-devel libpq-devel libssh2-devel libidn2-devel gettext-devel coreutils openssl-devel zip unzip - - name: Install Cygwin Packages + - name: Install Cygwin Packages with bash + if: 0 shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | ls -lah /cygdrive/c/ ls -lah /cygdrive/d/ - cp -f /cygdrive/c/setup.exe /cygdrive/c/cygwin/bin/setup-x86_64.exe - bash ./sapi/scripts/cygwin/install-cygwin.sh + - name: Install Cygwin Packages + if: 1 + run: | + Copy-Item -Path "C:\setup.exe" -Destination "${{ github.workspace }}\setup-x86_64.exe" + cmd /c .\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + - name: Install re2c + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/install-re2c.sh - name: Configure + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | uname -a # git config --global --add safe.directory /cygdrive/d/a/swoole-cli/swoole-cli @@ -63,6 +83,7 @@ jobs: bash ./sapi/scripts/cygwin/cygwin-config.sh - name: Build + shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} run: | bash ./sapi/scripts/cygwin/cygwin-build.sh @@ -112,8 +133,30 @@ jobs: - name: gh release uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: swoole-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip + + upload-to-cloud-object-storage: + if: 1 + runs-on: ubuntu-latest + needs: windows-cygwin + steps: + - name: Prepare Run Environment + run: + sudo apt install -y curl + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: upload artifacts to cloud object storage + if: ${{ (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: | + FILE_NAME=$(ls -d swoole-cli-v*-cygwin-x64) + FILE="${{ github.workspace }}/${FILE_NAME}/${FILE_NAME}.zip" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${FILE} diff --git a/composer.lock b/composer.lock index 12ff82e2e0..ad962a61bc 100644 --- a/composer.lock +++ b/composer.lock @@ -161,13 +161,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "3.x-dev" } }, "autoload": { @@ -540,16 +540,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.65.0", + "version": "v3.66.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f" + "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f", - "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/5f5f2a142ff36b93c41885bca29cc5f861c013e6", + "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6", "shasum": "" }, "require": { @@ -575,7 +575,7 @@ "symfony/polyfill-mbstring": "^1.28", "symfony/polyfill-php80": "^1.28", "symfony/polyfill-php81": "^1.28", - "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/process": "^5.4 || ^6.0 || ^7.0 <7.2", "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { @@ -631,7 +631,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.66.0" }, "funding": [ { @@ -639,7 +639,7 @@ "type": "github" } ], - "time": "2024-11-25T00:39:24+00:00" + "time": "2024-12-29T13:46:23+00:00" }, { "name": "myclabs/deep-copy", @@ -703,16 +703,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.3.1", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", - "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { @@ -755,9 +755,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-10-08T18:51:32+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "phar-io/manifest", @@ -3170,12 +3170,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -3318,12 +3318,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4130,12 +4130,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { diff --git a/docs/Cygwin.md b/docs/Cygwin.md index 2c53dd0e44..5fd4679cab 100755 --- a/docs/Cygwin.md +++ b/docs/Cygwin.md @@ -12,21 +12,43 @@ > 命令行同时安装多个包,包名之间使用逗号隔开 +## windows 环境下 配置 git 环境 + +1. 禁止Git在提交和检出时进行换行符的自动转换‌ +2. 使用`lf` 作为换行符 +3. 区分大小写 + +```shell + +# 下载git +curl.exe -fSLo Git-2.47.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe + +# 命令行静默安装 git +start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + + +git config --global core.autocrlf false +git config --global core.eol lf +git config --global core.ignorecase false + +``` + ## 安装cygwin 和 cygwin 依赖项 -> 打开 windows 控制台,并找到 setup-x86_64.exe 所在目录, 将 setup-x86_64.exe 复制到 `sapi\quickstart\windows\` 目录 -> 执行如下命令 +> 打开windows CMD 终端,进入项目目录 ,执行如下命令 ```bash # 自动安装 cygwin 和 cygwin 依赖项 -sapi\quickstart\windows\install-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\download-cygwin.bat +.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat + ``` 构建步骤 - 执行的命令 ==== -> 运行如下步骤,需要先 打开 cygwin64 Terminal +> 运行如下步骤,打开 cygwin64 Terminal, 并进入项目目录,执行如下命令 ```shell @@ -122,14 +144,16 @@ libzstd-devel ## 安装 cygwin 和 安装 cygwin 依赖项 具体执行的命令 -> `sapi\quickstart\windows\install-cygwin.bat` 脚本包含的内容 +> 多个包之间 使用逗号分隔 + +> 编辑修改此文件即可 `.\sapi\quickstart\windows\cygwin-build\install-cygwin.bat` ```bash # 安装 cygwin -setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ +setup-x86_64.exe --site https://mirrors.ustc.edu.cn/cygwin/ # 安装 cygwin 依赖项 -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip icu libicu-devel diff --git a/docs/options.md b/docs/options.md index de5b9363ce..78ee45e6dc 100644 --- a/docs/options.md +++ b/docs/options.md @@ -163,8 +163,6 @@ with-libavif ---- GD库支持 AVIF图片格式 - with-iouring ---- swoole 启用支持 iouring 特性 - diff --git a/ext/swoole b/ext/swoole index df1f708b22..a0a1ed8131 160000 --- a/ext/swoole +++ b/ext/swoole @@ -1 +1 @@ -Subproject commit df1f708b22440110aff8c125244d3de56569ed8c +Subproject commit a0a1ed81319c2a7d8b85875384cbcf0a68d42ae4 diff --git a/sapi/download-box/download-box-get-archive-from-server.sh b/sapi/download-box/download-box-get-archive-from-server.sh index fadbd0a624..723656c44a 100644 --- a/sapi/download-box/download-box-get-archive-from-server.sh +++ b/sapi/download-box/download-box-get-archive-from-server.sh @@ -18,9 +18,9 @@ test -d ${__PROJECT__}/var/download-box/ || mkdir -p ${__PROJECT__}/var/download cd ${__PROJECT__}/var/download-box/ -ALL_DEPS_HASH="bdd159b93fd8217e89d206aeb22bf7a8295553db0aff332f049b9025feb31766" +ALL_DEPS_HASH="a55699ecee994032f33266dfa37eabb49f1f6d6b6b65cdcf7b881cac09c63bea" -DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v5.1.5.1/' +DOMAIN='https://github.com/swoole/swoole-cli/releases/download/v6.0.0.0/' while [ $# -gt 0 ]; do case "$1" in @@ -38,7 +38,7 @@ done URL="${DOMAIN}/all-deps.zip" -test -f all-deps.zip || curl -Lo all-deps.zip ${URL} +test -f all-deps.zip || curl -fSLo all-deps.zip ${URL} # hash 签名 HASH=$(sha256sum all-deps.zip | awk '{print $1}') diff --git a/sapi/quickstart/linux/arm64/README.md b/sapi/quickstart/linux/arm64/README.md index d22e0344b3..8c4031d9a9 100644 --- a/sapi/quickstart/linux/arm64/README.md +++ b/sapi/quickstart/linux/arm64/README.md @@ -1,18 +1,13 @@ -# x86_64 运行 arm64 -> 使用 qemu-user-static 实现 +# 在 `x86_64` 平台模拟 `arm64` -## 参考文档 -qemu - https://www.qemu.org/ - https://github.com/qemu/qemu.git - -qemu-user-static - https://github.com/multiarch/qemu-user-static.git +使用 `qemu-user-static` 实现 -x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建 - https://www.cnblogs.com/chen2ha/p/17180287.html +## 参考文档 -Docker在x86架构的物理机上跑Qemu-arm 容器 - https://blog.csdn.net/sunSHINEEzy/article/details/80015638 +- [qemu 官网](https://www.qemu.org/) +- [qemu GitHub](https://github.com/qemu/qemu.git) +- [qemu-user-static](https://github.com/multiarch/qemu-user-static.git) +- [x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建](https://www.cnblogs.com/chen2ha/p/17180287.html) +- [Docker在x86架构的物理机上跑Qemu-arm 容器](https://blog.csdn.net/sunSHINEEzy/article/details/80015638) diff --git a/sapi/quickstart/linux/connection-swoole-cli-alpine.sh b/sapi/quickstart/linux/connection-swoole-cli-alpine.sh index f39d9b749f..a90c7ed051 100644 --- a/sapi/quickstart/linux/connection-swoole-cli-alpine.sh +++ b/sapi/quickstart/linux/connection-swoole-cli-alpine.sh @@ -8,5 +8,4 @@ __DIR__=$( cd ${__DIR__} -docker exec -it swoole-cli-alpine-dev sh - +docker exec -it woole-cli-builder sh diff --git a/sapi/quickstart/linux/extra/README.md b/sapi/quickstart/linux/extra/README.md index fb66c41799..b91578ba94 100644 --- a/sapi/quickstart/linux/extra/README.md +++ b/sapi/quickstart/linux/extra/README.md @@ -1,25 +1,25 @@ -# +# 常见问题 -## 当环境中没有 PHP 解释器时 可以快速安装 PHP 解释器 -```bash - -# alpine - -sh sapi/quickstart/linux/extra/alpine-php-init.sh +## 快速安装 `PHP` 解释器 -## debian +### Alpine +```bash +sh sapi/quickstart/linux/extra/alpine-php-init.sh +``` +### Debian/Ubuntu +```bash bash sapi/quickstart/linux/extra/debian-php-init.sh - ``` -```bash - wget -O composer.phar https://mirrors.aliyun.com/composer/composer.phar +## 安装 `Composer` +```bash +wget -O composer.phar https://mirrors.aliyun.com/composer/composer.phar ``` -## c c++编译器 组合 +## `C/C++` 编译器组合 -- 组合一 clang clang++ -- 组合二 gcc g++ +- `clang` + `clang++` +- `gcc` + `g++` diff --git a/sapi/quickstart/linux/install-docker-compose.sh b/sapi/quickstart/linux/install-docker-compose.sh index 1fe7107d8d..d1ed6900a8 100644 --- a/sapi/quickstart/linux/install-docker-compose.sh +++ b/sapi/quickstart/linux/install-docker-compose.sh @@ -24,7 +24,7 @@ if [ ! -f /usr/libexec/docker/cli-plugins/docker-compose ]; then # show more version info # https://github.com/docker/compose/releases - VERSION="v2.29.1" + VERSION="v2.32.1" curl -fsSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose diff --git a/sapi/quickstart/linux/install-docker.sh b/sapi/quickstart/linux/install-docker.sh index ebdcf2a8ef..860c6f21a6 100644 --- a/sapi/quickstart/linux/install-docker.sh +++ b/sapi/quickstart/linux/install-docker.sh @@ -28,7 +28,6 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done - # https://github.com/docker/docker-install.git # test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh @@ -41,14 +40,15 @@ china | ustc | tuna) ;; esac - if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then - echo 'Please delete proxy settings !' - echo 'Execute this script again !' - exit 0 + set +u + unset http_proxy + unset https_proxy + unset HTTP_PROXY + unset HTTPS_PROXY + set -u fi - case "$MIRROR" in china | ustc) sed -i "s@https://mirrors.aliyun.com/docker-ce@https://mirrors.ustc.edu.cn/docker-ce@g" get-docker.sh diff --git a/sapi/quickstart/linux/run-alpine-container-full.sh b/sapi/quickstart/linux/run-alpine-container-full.sh index d9042de1f4..27003d3697 100644 --- a/sapi/quickstart/linux/run-alpine-container-full.sh +++ b/sapi/quickstart/linux/run-alpine-container-full.sh @@ -12,7 +12,7 @@ __PROJECT__=$( cd ${__DIR__} { - docker stop swoole-cli-alpine-dev + docker stop swoole-cli-builder sleep 5 } || { echo $? @@ -21,7 +21,7 @@ cd ${__DIR__} IMAGE=alpine:3.18 -:<<'EOF' +: <<'EOF' 启动此容器 已经内置了 php 、composer 、 编译好的依赖库 @@ -51,16 +51,16 @@ case $ARCH in 'x86_64') TAG=all-dependencies-alpine-3.18-php8-v1.0.0-x86_64-20240715T132512Z IMAGE=docker.io/jingjingxyk/build-swoole-cli:${TAG} - if [ "$MIRROR" = 'china' ] ; then + if [ "$MIRROR" = 'china' ]; then IMAGE=registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:${TAG} fi ;; 'aarch64') TAG=all-dependencies-alpine-3.18-php8-v1.0.0-aarch64-20240618T091126Z IMAGE=docker.io/jingjingxyk/build-swoole-cli:${TAG} - if [ "$MIRROR" = 'china' ] ; then - IMAGE=registry.cn-hangzhou.aliyuncs.com/jingjingxyk-public/app:${TAG} - fi + if [ "$MIRROR" = 'china' ]; then + IMAGE=registry.cn-hangzhou.aliyuncs.com/jingjingxyk-public/app:${TAG} + fi ;; *) echo "此 ${ARCH} 架构的容器 容器未配置" @@ -68,14 +68,12 @@ case $ARCH in ;; esac - cd ${__DIR__} -if [ $DEV_SHM -eq 1 ] ; then +if [ $DEV_SHM -eq 1 ]; then mkdir -p /dev/shm/swoole-cli/thirdparty/ mkdir -p /dev/shm/swoole-cli/ext/ - docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work --init $IMAGE tail -f /dev/null + docker run --rm --name swoole-cli-builder -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work --init $IMAGE tail -f /dev/null else - docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null + docker run --rm --name swoole-cli-builder -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null fi - diff --git a/sapi/quickstart/linux/run-alpine-container.sh b/sapi/quickstart/linux/run-alpine-container.sh index 4caaa6f7bf..c402ac11f2 100644 --- a/sapi/quickstart/linux/run-alpine-container.sh +++ b/sapi/quickstart/linux/run-alpine-container.sh @@ -12,7 +12,7 @@ __PROJECT__=$( cd ${__DIR__} { - docker stop swoole-cli-alpine-dev + docker stop swoole-cli-builder sleep 5 } || { echo $? @@ -27,9 +27,9 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" case "$MIRROR" in - china | openatom) - IMAGE="hub.atomgit.com/library/alpine:3.18" - ;; + china | openatom) + IMAGE="hub.atomgit.com/library/alpine:3.18" + ;; esac ;; esac @@ -37,4 +37,4 @@ while [ $# -gt 0 ]; do done cd ${__DIR__} -docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null +docker run --rm --name swoole-cli-builder -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null diff --git a/sapi/quickstart/linux/run-debian-container.sh b/sapi/quickstart/linux/run-debian-container.sh index 1e3768a605..b58527b544 100644 --- a/sapi/quickstart/linux/run-debian-container.sh +++ b/sapi/quickstart/linux/run-debian-container.sh @@ -27,15 +27,14 @@ while [ $# -gt 0 ]; do --mirror) MIRROR="$2" case "$MIRROR" in - china | openatom) - IMAGE="hub.atomgit.com/library/debian:12" - ;; + china | openatom) + IMAGE="hub.atomgit.com/library/debian:12" + ;; esac ;; esac shift $(($# > 0 ? 1 : 0)) done - cd ${__DIR__} docker run --rm --name swoole-cli-debian-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null diff --git a/sapi/quickstart/windows/README.md b/sapi/quickstart/windows/cygwin-build/README.md similarity index 51% rename from sapi/quickstart/windows/README.md rename to sapi/quickstart/windows/cygwin-build/README.md index f7df0e7867..23937d8589 100644 --- a/sapi/quickstart/windows/README.md +++ b/sapi/quickstart/windows/cygwin-build/README.md @@ -1,15 +1,15 @@ # windows 快速准备构建环境 -## [windows cygwin 环境 构建步骤](../../../docs/Cygwin.md) +## [windows cygwin 环境 构建步骤](../../../../docs/Cygwin.md) ## 双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库 ```shell # 自动下载 cygwin -sapi\quickstart\windows\download-cygwin.bat -# 自动安装 cygwin -sapi\quickstart\windows\install-cygwin.bat +sapi\quickstart\windows\cygwin-build\download-cygwin.bat +# 自动安装 依赖包 +sapi\quickstart\windows\cygwin-build\install-cygwin.bat ``` diff --git a/sapi/quickstart/windows/cygwin-build/download-cygwin.bat b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat new file mode 100644 index 0000000000..1b5e928bf8 --- /dev/null +++ b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat @@ -0,0 +1,23 @@ +@echo off +:: cygwin site: https://cygwin.com/ +:: start https://cygwin.com/setup-x86_64.exe + +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-cygwin-build-deps\ + +cd /d %__PROJECT__%\var\windows-cygwin-build-deps\ + +curl.exe -fSLo setup-x86_64.exe https://cygwin.com/setup-x86_64.exe + +copy .\setup-x86_64.exe %__PROJECT__%\ + +endlocal diff --git a/sapi/quickstart/windows/cygwin-build/install-cygwin.bat b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat new file mode 100644 index 0000000000..947c6fa2d4 --- /dev/null +++ b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat @@ -0,0 +1,42 @@ +@echo off + +:: cygwin site: https://cygwin.com/ +:: start https://cygwin.com/setup-x86_64.exe + +setlocal enableextensions enabledelayedexpansion + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +cd /d %__PROJECT__%\ +echo %cd% +:: package separate with commas + + +set SITE="https://mirrors.kernel.org/sourceware/cygwin/" + +:getopt +if /i "%1" equ "--mirror" ( + if /i "%2" equ "china" ( + set SITE="https://mirrors.ustc.edu.cn/cygwin/" + ) +) +shift + +if not (%1)==() goto getopt + +if "%GITHUB_ACTIONS%"=="" ( + setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site %SITE% +) + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages zip unzip + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libpq5 libpq-devel + +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site %SITE% --packages libzstd-devel + +endlocal diff --git a/sapi/quickstart/windows/download-cygwin.bat b/sapi/quickstart/windows/download-cygwin.bat deleted file mode 100644 index 25086a1f0b..0000000000 --- a/sapi/quickstart/windows/download-cygwin.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -:: cygwin site: https://cygwin.com/ -start https://cygwin.com/setup-x86_64.exe diff --git a/sapi/quickstart/windows/install-cygwin.bat b/sapi/quickstart/windows/install-cygwin.bat deleted file mode 100644 index 66ca23fe2d..0000000000 --- a/sapi/quickstart/windows/install-cygwin.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off -:: cygwin安装多个包,包之间,用逗号分隔 - -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages zip unzip - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libpq5 libpq-devel - -setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libzstd-devel - diff --git a/sapi/scripts/cygwin/cygwin-build.sh b/sapi/scripts/cygwin/cygwin-build.sh index 36386243da..2c4594122c 100755 --- a/sapi/scripts/cygwin/cygwin-build.sh +++ b/sapi/scripts/cygwin/cygwin-build.sh @@ -13,5 +13,18 @@ cd ${__PROJECT__} mkdir -p bin/.libs # export LDFLAGS="-all-static" -make -j $(nproc) +LOGICAL_PROCESSORS=$(nproc) + +set +u +if [ -n "${GITHUB_ACTION}" ]; then + if test $LOGICAL_PROCESSORS -ge 4; then + LOGICAL_PROCESSORS=$((LOGICAL_PROCESSORS - 2)) + fi + make + # make -j $LOGICAL_PROCESSORS +else + make -j $LOGICAL_PROCESSORS +fi +set -u + ./bin/swoole-cli -v diff --git a/sapi/scripts/cygwin/install-cygwin.sh b/sapi/scripts/cygwin/install-cygwin.sh index 79d61128a9..6971f19e5a 100644 --- a/sapi/scripts/cygwin/install-cygwin.sh +++ b/sapi/scripts/cygwin/install-cygwin.sh @@ -42,10 +42,10 @@ while [ $# -gt 0 ]; do shift $(($# > 0 ? 1 : 0)) done -# setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel,zip,unzip +# setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,zip,unzip #setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site http://mirrors.ustc.edu.cn/cygwin/ --packages -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel,zip,unzip +setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site $SITE --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,zip,unzip setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages zip unzip icu libicu-devel setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libpq5 libpq-devel setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site $SITE --packages libzstd-devel diff --git a/sapi/scripts/download-php-src-archive.php b/sapi/scripts/download-php-src-archive.php index 0644a48a67..3c193dd247 100644 --- a/sapi/scripts/download-php-src-archive.php +++ b/sapi/scripts/download-php-src-archive.php @@ -7,7 +7,7 @@ $download_dir = dirname($php_archive_file); # 下载 PHP 源码 -$download_cmd = "curl -L https://github.com/php/php-src/archive/refs/tags/php-{$php_version_tag}.tar.gz -o {$php_archive_file}"; +$download_cmd = "curl -fSL https://github.com/php/php-src/archive/refs/tags/php-{$php_version_tag}.tar.gz -o {$php_archive_file}"; echo $download_cmd . PHP_EOL; if (!file_exists($php_archive_file)) { `test -d {$download_dir} || mkdir -p {$download_dir}`; diff --git a/sapi/scripts/generate-artifact-hash.sh b/sapi/scripts/generate-artifact-hash.sh index 4de2b17ac2..f717760043 100644 --- a/sapi/scripts/generate-artifact-hash.sh +++ b/sapi/scripts/generate-artifact-hash.sh @@ -99,7 +99,7 @@ UNIX_DOWNLOAD_SWOOLE_CLIE_RUNTIME() { APP_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" - test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} } @@ -112,9 +112,8 @@ ARCH="x64" APP_DOWNLOAD_URL="https://github.com/swoole/swoole-cli/releases/download/${VERSION}/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" -test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} -test -f all-deps.zip || curl -LSo all-deps.zip https://github.com/swoole/swoole-cli/releases/download/${VERSION}/all-deps.zip - +test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} +test -f all-deps.zip || curl -fSLo all-deps.zip https://github.com/swoole/swoole-cli/releases/download/${VERSION}/all-deps.zip ls -p | grep -v '/$' | xargs sha256sum ls -p | grep -v '/$' | xargs sha256sum >${__PROJECT__}/${VERSION}-sha256sum diff --git a/sapi/scripts/tencent-cloud-object-storage.sh b/sapi/scripts/tencent-cloud-object-storage.sh new file mode 100644 index 0000000000..ad3522bc03 --- /dev/null +++ b/sapi/scripts/tencent-cloud-object-storage.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../ + pwd +) +cd ${__PROJECT__} + +## tencentyun upload oss +## 下载与安装配置 +## https://cloud.tencent.com/document/product/436/63144 + +APP_VERSION="v1.0.3" +APP_NAME="coscli" +APP_RUNTIME="${APP_NAME}-${APP_VERSION}" + +OS=$(uname -s) +ARCH=$(uname -m) + +case $OS in +'Linux') + APP_RUNTIME+='-linux' + ;; +'Darwin') + APP_RUNTIME+='-darwin' + ;; +*) + case $OS in + 'MSYS_NT'* | 'MINGW64_NT'* | 'CYGWIN_NT'*) + OS="windows" + APP_RUNTIME+='-windows' + echo ' 暂不支持 ' + exit 0 + ;; + *) + echo 'NO SUPPORT OS' + exit 0 + ;; + esac + + ;; +esac + +case $ARCH in +'x86_64') + APP_RUNTIME+='-amd64' + ;; +'aarch64' | 'arm64') + APP_RUNTIME+='-arm64' + ;; +*) + echo 'NO SUPPORT CPU ARCH ' + exit 0 + ;; +esac + +SWOOLE_CLI_VERSION='v6.0.0.0' +SWOOLE_VERSION='v6.0.0' +UPLOAD_FILE='' +UPLOAD_TYPE='' +PROXY_OPTION='' +while [ $# -gt 0 ]; do + case "$1" in + --swoole-cli-version) + SWOOLE_CLI_VERSION="$2" + ;; + --upload-file) + UPLOAD_FILE="$2" + UPLOAD_TYPE='single' + ;; + --upload-all) + UPLOAD_TYPE='all' + ;; + --proxy) + export HTTP_PROXY="$2" + export HTTPS_PROXY="$2" + NO_PROXY="127.0.0.0/8,10.0.0.0/8,100.64.0.0/10,172.16.0.0/12,192.168.0.0/16" + NO_PROXY="${NO_PROXY},::1/128,fe80::/10,fd00::/8,ff00::/8" + NO_PROXY="${NO_PROXY},localhost" + export NO_PROXY="${NO_PROXY},.myqcloud.com,.swoole.com" + PROXY_OPTION="--proxy $2" + ;; + --show) + UPLOAD_TYPE="show" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +mkdir -p ${__PROJECT__}/var/tencent-cloud-object-storage/ +cd ${__PROJECT__}/var/tencent-cloud-object-storage/ + +CLOUD_OBJECT_STORAGE_CONFIG=${__PROJECT__}/var/tencent-cloud-object-storage/.tencent-cloud-object-storage.yaml +if [ ! -f ${CLOUD_OBJECT_STORAGE_CONFIG} ]; then + cp -f ${__PROJECT__}/sapi/scripts/tencent-cloud-object-storage.yaml ${CLOUD_OBJECT_STORAGE_CONFIG} + set +u + if [ -n "${OSS_SECRET_ID}" ] && [ -n "${OSS_SECRET_KEY}" ]; then + sed -i.bak "s/\${{ secrets.QCLOUD_OSS_SECRET_ID }}/${OSS_SECRET_ID}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ secrets.QCLOUD_OSS_SECRET_KEY }}/${OSS_SECRET_KEY}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ vars.QCLOUD_OSS_BUCKET }}/${OSS_BUCKET}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + sed -i.bak "s/\${{ vars.QCLOUD_OSS_REGION }}/${OSS_REGION}/" ${CLOUD_OBJECT_STORAGE_CONFIG} + fi + set -u +fi + +if [ "${OS}" == 'windows' ]; then + APP_RUNTIME+=".exe" +fi + +test -f ${APP_RUNTIME} || curl -fSLo ${APP_RUNTIME} https://github.com/tencentyun/coscli/releases/download/${APP_VERSION}/${APP_RUNTIME} +chmod a+x ${APP_RUNTIME} + +BUCKET_NAME=$(grep "\- name: " ${CLOUD_OBJECT_STORAGE_CONFIG} | sed 's/\- name: //g' | sed 's/^ *//;s/ *$//' | tr -d '"') +COSCLI="${__PROJECT__}/var/tencent-cloud-object-storage/${APP_RUNTIME} --config-path ${CLOUD_OBJECT_STORAGE_CONFIG} --log-path ${__PROJECT__}/var/tencent-cloud-object-storage/coscli.log " +COS_BUCKET_FOLDER="cos://${BUCKET_NAME}/dist/" + +if [ "${UPLOAD_TYPE}" == 'all' ]; then + if [ ! -d ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} ]; then + bash ${__PROJECT__}/sapi/scripts/generate-artifact-hash.sh --version ${SWOOLE_CLI_VERSION} ${PROXY_OPTION} + fi +fi + +set +u +if [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then + unset $HTTP_PROXY + unset $HTTPS_PROXY +fi +set -u + +if [ "${UPLOAD_TYPE}" == 'all' ]; then + SWOOLE_VERSION=$(echo ${SWOOLE_CLI_VERSION} | awk -F '.' '{ printf "%s.%s.%s" ,$1,$2,$3 }') + cd ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} sync swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} + cd ${__PROJECT__} + exit 0 +fi + +if [ "${UPLOAD_TYPE}" == 'single' ]; then + ${COSCLI} sync ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} + exit 0 +fi + +if [ "${UPLOAD_TYPE}" == 'show' ]; then + # cat ${CLOUD_OBJECT_STORAGE_CONFIG} + # ${COSCLI} --help + ${COSCLI} ls ${COS_BUCKET_FOLDER} + exit 0 +fi diff --git a/sapi/scripts/tencent-cloud-object-storage.yaml b/sapi/scripts/tencent-cloud-object-storage.yaml new file mode 100644 index 0000000000..dc7e963fb0 --- /dev/null +++ b/sapi/scripts/tencent-cloud-object-storage.yaml @@ -0,0 +1,17 @@ +cos: + base: + secretid: "${{ secrets.QCLOUD_OSS_SECRET_ID }}" + secretkey: "${{ secrets.QCLOUD_OSS_SECRET_KEY }}" + sessiontoken: "" + protocol: https + mode: SecretKey + cvmrolename: "" + closeautoswitchhost: "true" + buckets: + - name: "${{ vars.QCLOUD_OSS_BUCKET }}" + alias: "${{ vars.QCLOUD_OSS_BUCKET }}" + region: "${{ vars.QCLOUD_OSS_REGION }}" + # endpoint: cos.ap-shanghai.myqcloud.com + # endpoint: wenda-1252906962.cos.accelerate.myqcloud.com + endpoint: "cos.accelerate.myqcloud.com" + ofs: false diff --git a/sapi/scripts/tencentyun-upload-oss.sh b/sapi/scripts/tencentyun-upload-oss.sh deleted file mode 100644 index bd0e736089..0000000000 --- a/sapi/scripts/tencentyun-upload-oss.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -exu -__DIR__=$( - cd "$(dirname "$0")" - pwd -) -__PROJECT__=$( - cd ${__DIR__}/../../../ - pwd -) -cd ${__PROJECT__} - -exit 0 - -## tencentyun upload oss -## 下载与安装配置 -## https://cloud.tencent.com/document/product/436/63144 - -test -f coscli-windows.exe || wget https://github.com/tencentyun/coscli/releases/download/v0.13.0-beta/coscli-windows.exe - -./coscli-windows cp swoole-cli-v".SWOOLE_VERSION."-cygwin-x64 cos://examplebucket-1250000000/test.txt -e cos.ap-chengdu.myqcloud.com - - diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 7a049f1351..c1288ffd43 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -299,7 +299,7 @@ protected function downloadFile(string $url, string $file, ?object $project = nu if ($this->getInputOption('with-downloader') === 'wget') { $cmd = "wget {$url} -O {$file} -t {$retry_number} --wait={$wait_retry} -T {$connect_timeout} "; } else { - $cmd = "curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -Lo '{$file}' '{$url}' "; + $cmd = "curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -fSLo '{$file}' '{$url}' "; } echo $cmd; echo PHP_EOL; @@ -794,7 +794,9 @@ public function execute(): void } $this->generateFile(__DIR__ . '/template/make.php', $this->rootDir . '/make.sh'); - shell_exec('chmod a+x '.$this->rootDir . '/make.sh'); + + shell_exec('chmod a+x ' . $this->rootDir . '/make.sh'); + $this->mkdirIfNotExists($this->rootDir . '/bin'); $this->generateFile(__DIR__ . '/template/license.php', $this->rootDir . '/bin/LICENSE'); $this->generateFile(__DIR__ . '/template/credits.php', $this->rootDir . '/bin/credits.html'); diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index 4db0371f11..03afccdeb7 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -1,4 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash __PROJECT_DIR__=$(cd "$(dirname "$0")"; pwd) CLI_BUILD_TYPE=getBuildType() . PHP_EOL ?> SRC=phpSrcDir . PHP_EOL ?> diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 05d4a882ee..7707875f08 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -39,7 +39,7 @@ case $ARCH in 'x86_64') ARCH="x64" ;; -'aarch64' | 'arm64' ) +'aarch64' | 'arm64') ARCH="arm64" ;; *) @@ -99,23 +99,23 @@ china) esac -test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +test -f composer.phar || curl -fSLo composer.phar ${COMPOSER_DOWNLOAD_URL} chmod a+x composer.phar -test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} +test -f cacert.pem || curl -fSLo cacert.pem ${CACERT_DOWNLOAD_URL} APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" if [ $OS = 'windows' ]; then { APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" - test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} unzip "${APP_RUNTIME}.zip" exit 0 } else - test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz test -f swoole-cli && rm -f swoole-cli tar -xvf ${APP_RUNTIME}.tar @@ -166,4 +166,3 @@ test $OS="macos" && echo "sudo xattr -d com.apple.quarantine ${__PROJECT__}/bin/ echo " " export PATH="${__PROJECT__}/bin/runtime:$PATH" php -v - diff --git a/setup-swoole-cli-runtime.sh b/setup-swoole-cli-runtime.sh index 6e0c5d9d00..fd085383f1 100644 --- a/setup-swoole-cli-runtime.sh +++ b/setup-swoole-cli-runtime.sh @@ -48,9 +48,9 @@ case $ARCH in ;; esac -APP_VERSION='v5.1.5' +APP_VERSION='v6.0.0' APP_NAME='swoole-cli' -VERSION='v5.1.5.1' +VERSION='v6.0.0.0' MIRROR='' while [ $# -gt 0 ]; do @@ -124,24 +124,24 @@ china) esac -test -f composer.phar || curl -LSo composer.phar ${COMPOSER_DOWNLOAD_URL} +test -f composer.phar || curl -fSLo composer.phar ${COMPOSER_DOWNLOAD_URL} chmod a+x composer.phar -test -f cacert.pem || curl -LSo cacert.pem ${CACERT_DOWNLOAD_URL} +test -f cacert.pem || curl -fSLo cacert.pem ${CACERT_DOWNLOAD_URL} APP_RUNTIME="${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}" if [ $OS = 'windows' ]; then { APP_RUNTIME="${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}" - test -f ${APP_RUNTIME}.zip || curl -LSo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.zip || curl -fSLo ${APP_RUNTIME}.zip ${APP_DOWNLOAD_URL} test -d ${APP_RUNTIME} && rm -rf ${APP_RUNTIME} unzip "${APP_RUNTIME}.zip" echo exit 0 } else - test -f ${APP_RUNTIME}.tar.xz || curl -LSo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} + test -f ${APP_RUNTIME}.tar.xz || curl -fSLo ${APP_RUNTIME}.tar.xz ${APP_DOWNLOAD_URL} test -f ${APP_RUNTIME}.tar || xz -d -k ${APP_RUNTIME}.tar.xz test -f swoole-cli && rm -f swoole-cli tar -xvf ${APP_RUNTIME}.tar