CI on x86_64 linux #80
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: CI on x86_64 linux | |
on: | |
workflow_dispatch: | |
inputs: | |
operating-system: | |
required: true | |
description: Compile target x86_64 (Linux only) | |
type: choice | |
options: | |
- x86_64 | |
build-cli: | |
description: build cli binary | |
default: true | |
type: boolean | |
build-micro: | |
description: build phpmicro binary | |
type: boolean | |
build-fpm: | |
description: build fpm binary | |
type: boolean | |
prefer-pre-built: | |
description: prefer pre-built binaries (reduce build time) | |
type: boolean | |
default: true | |
debug: | |
description: enable debug logs | |
type: boolean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build: | |
name: Build Linux x86_64 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: ['8.4', '8.3', '8.2', '8.1', '8.0'] | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "SPC_BUILD_OS=linux" >> $GITHUB_ENV | |
- name: "Setup PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
tools: pecl, composer | |
extensions: curl, openssl, mbstring, tokenizer | |
ini-values: memory_limit=-1 | |
# Cache composer dependencies | |
- id: cache-composer-deps | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: composer-dependencies | |
# name: Set default extensions | |
- run: echo "extensions=amqp,apcu,bcmath,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,gd,gettext,iconv,igbinary,imagick,libxml,mbregex,mbstring,mongodb,msgpack,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pdo_sqlsrv,pgsql,phar,posix,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,sqlsrv,sysvmsg,sysvsem,sysvshm,tokenizer,xlswriter,xml,xmlreader,xmlwriter,xsl,zip,zlib" >> $GITHUB_ENV | |
# If there's no Composer cache, install dependencies | |
- if: steps.cache-composer-deps.outputs.cache-hit != 'true' | |
run: composer update --no-dev --classmap-authoritative | |
# With or without debug | |
- if: inputs.debug == true | |
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV | |
- if: inputs.prefer-pre-built == true | |
run: echo "SPC_PRE_BUILT=--prefer-pre-built" >> $env:GITHUB_ENV | |
# With target select: cli, micro or both | |
- if: ${{ inputs.build-cli == true }} | |
run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV | |
- if: ${{ inputs.build-micro == true }} | |
run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV | |
- if: ${{ inputs.build-fpm == true }} | |
run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV | |
- run: ./bin/spc doctor | |
# If there's no dependencies cache, fetch sources, with or without debug | |
- run: ./bin/spc download --with-php=${{ matrix.version }} --for-extensions=${{ env.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_PRE_BUILT }} | |
- run: ./bin/spc switch-php-version ${{ matrix.version }} | |
# Run build command | |
- run: ./bin/spc build ${{ env.extensions }} --with-libs="freetype,libjpeg,libwebp" -I "opcache.enable_cli=1" -I "opcache.jit_buffer_size=32M" -I "apc.enable_cli=1" -I "memory_limit=256M" -I "openssl.cafile=/etc/ssl/certs/ca-certificates.crt" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} | |
#- run: ./bin/spc build ${{ env.extensions }} --with-libs="freetype,libjpeg,libwebp" -I "memory_limit=256M" -I "openssl.cafile=/etc/ssl/certs/ca-certificates.crt" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} | |
# Pack PHP to archive | |
- run: mkdir dist2 && cp buildroot/bin/php dist2/ && cd dist2 && tar -zcvf "php-${{ matrix.version }}-linux-${{ inputs.operating-system }}.tar.gz" ./php && rm ./php | |
- if: ${{ inputs.build-micro == true }} | |
run: cp buildroot/bin/micro.sfx dist2/php${{ matrix.version }}.micro.sfx && cd dist2 && zip php${{ matrix.version }}.micro.sfx.zip ./php${{ matrix.version }}.micro.sfx | |
# Deploy | |
- if: ${{ inputs.build-cli == true }} | |
uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} | |
ARGS: "-rltgoDzvO" | |
SOURCE: "dist2/" | |
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }} | |
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }} | |
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }} | |
TARGET: ${{ secrets.DEPLOY_SERVER_TARGET }} | |