|
| 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 |
0 commit comments