Skip to content

Cache PHP for stable versions #64

Cache PHP for stable versions

Cache PHP for stable versions #64

Workflow file for this run

name: Cache PHP for stable versions
on:
push:
workflow_dispatch:
inputs:
php-versions:
description: 'PHP version to build'
default: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4'
required: false
builds:
description: 'Build type'
default: 'debug release'
required: false
ts:
description: 'Type safety'
default: 'nts zts'
required: false
containers:
description: 'OS containers'
default: '24.04 22.04 20.04'
required: false
env:
PHP_VERSIONS: '5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4'
BUILDS: 'debug release'
TS: 'nts zts'
CONTAINERS: '24.04 22.04 20.04'
jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Matrix
id: get-matrix
run: bash scripts/get-matrix.sh
env:
PHP_VERSIONS: ${{ inputs.php-versions || env.PHP_VERSIONS }}
BUILDS: ${{ inputs.builds || env.BUILDS }}
TS: ${{ inputs.ts || env.TS }}
CONTAINERS: ${{ inputs.containers || env.CONTAINERS }}
cache:
needs: get-matrix
container: ubuntu:${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
if: "!contains(github.event.head_commit.message, 'skip-cache')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install requirements
run: bash scripts/install-requirements.sh
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'false'
TS: ${{ matrix.ts }}
- name: Get ZSTD_DIR
id: zstd
run: echo "ZSTD_DIR=zstd-$(curl -sL https://github.com/facebook/zstd/releases/latest | grep -Po "tree/v(\d+\.\d+\.\d+)" | cut -d'v' -f 2 | head -n 1)" | tee -a "$GITHUB_OUTPUT"
- name: Add ZSTD
env:
CONTAINER: ${{ matrix.container }}
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.repository_owner }}
ZSTD_DIR: ${{ steps.zstd.outputs.ZSTD_DIR }}
run: bash scripts/install-zstd.sh
- name: Configure git
run: bash scripts/configure-git.sh
- name: Setup PHP
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'false'
TS: ${{ matrix.ts }}
run: bash scripts/install-php.sh
- name: Build package
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
TS: ${{ matrix.ts }}
run: bash scripts/package-php.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ubuntu-${{ matrix.container }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
path: builds
tests:
runs-on: ${{ matrix.os }}
needs: [get-matrix, cache]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
if: "!contains(github.event.head_commit.message, 'skip-tests')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
path: /tmp
- name: Patch script
run: sed -i -e '/releases/d' -e '$s/fix_packages//' -e '1s/$/\n\nset -x/' scripts/install.sh
- name: Setup PHP
run: bash scripts/install.sh ${{ matrix.php-versions }} ${{ matrix.builds }} ${{ matrix.ts }}
- name: Switch versions
run: |
sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm /usr/sbin/php-fpm${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm.sock /run/php/php${{ matrix.php-versions }}-fpm.sock
for tool in phpize php-config phpdbg php-cgi php phar.phar phar; do
sudo update-alternatives --set "$tool" /usr/bin/"$tool"${{ matrix.php-versions }}
done
- name: Test PHP
run: |
file /usr/bin/php${{ matrix.php-versions }}
php -v
php-config --version
php-fpm -v
php-cgi -v
phpize -v
php -m
sudo service php${{ matrix.php-versions }}-fpm status || exit 1
php -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-config --version | grep -q '${{ matrix.php-versions }}' || exit 1
phpize -v | grep -q "$(php-config --phpapi)" || exit 1
php-fpm -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-cgi -v | grep -q '${{ matrix.php-versions }}' || exit 1
- name: Test broken packages
run: sudo apt-get check
release:
runs-on: ubuntu-latest
needs: [get-matrix, cache, tests]
if: "!contains(github.event.head_commit.message, 'skip-release')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create builds directory
run: mkdir builds
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: builds
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install cloudsmith-cli
run: pip install --upgrade cloudsmith-cli
- name: Release
run: bash scripts/release.sh
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
GITHUB_MESSAGE: ${{ github.event.head_commit.message }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_WORKSPACE: ${{ github.workspace }}