Skip to content

Update CI workflow: add release job and improve configuration formatt… #62

Update CI workflow: add release job and improve configuration formatt…

Update CI workflow: add release job and improve configuration formatt… #62

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request_target:
types: [ opened, synchronize, reopened, review_requested ]
jobs:
tests:
name: Tests on PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
include:
- php-version: '8.1'
coverage: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, ctype, iconv, intl
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Create cache directories
run: |
mkdir -p var/cache
chmod -R 777 var/cache
- name: Run PHP CS Fixer (dry-run)
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run --diff --verbose
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress
- name: Run Rector (dry-run)
run: vendor/bin/rector --dry-run --no-progress-bar
- name: Run PHPUnit
if: ${{ !matrix.coverage }}
run: vendor/bin/phpunit
- name: Run PHPUnit with coverage
if: ${{ matrix.coverage }}
run: vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text
- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
release:
name: Create Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [ tests ]
permissions:
contents: write
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true