|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + syntax-check: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + if: startsWith(github.event.head_commit.message, '[Release]') |
| 12 | + |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + php: [ '7.4', '8.0', '8.1', '8.2' ] |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Setup PHP |
| 22 | + uses: shivammathur/setup-php@v2 |
| 23 | + with: |
| 24 | + php-version: ${{ matrix.php }} |
| 25 | + |
| 26 | + - name: Install Composer dependencies |
| 27 | + run: composer install --no-dev |
| 28 | + |
| 29 | + - name: Check PHP syntax |
| 30 | + run: find {src,tests} -type f -name "*.php" -exec php -l {} \; |
| 31 | + |
| 32 | + analyze-code: |
| 33 | + needs: syntax-check |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout code |
| 37 | + uses: actions/checkout@v3 |
| 38 | + |
| 39 | + - name: Setup PHP |
| 40 | + uses: shivammathur/setup-php@v2 |
| 41 | + with: |
| 42 | + php-version: '7.4' |
| 43 | + tools: php-cs-fixer, phpstan |
| 44 | + extensions: mbstring |
| 45 | + |
| 46 | + - name: Install Composer dependencies |
| 47 | + run: composer install |
| 48 | + |
| 49 | + - name: Run PHP-CS-Fixer |
| 50 | + run: php-cs-fixer fix --dry-run --diff |
| 51 | + |
| 52 | + - name: Run PHPStan |
| 53 | + run: phpstan analyse src tests --xdebug |
| 54 | + |
| 55 | + check-dependencies: |
| 56 | + needs: analyze-code |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout code |
| 61 | + uses: actions/checkout@v3 |
| 62 | + |
| 63 | + - name: Setup PHP |
| 64 | + uses: shivammathur/setup-php@v2 |
| 65 | + with: |
| 66 | + php-version: '7.4' |
| 67 | + |
| 68 | + - name: Install Composer dependencies |
| 69 | + run: composer install |
| 70 | + |
| 71 | + - name: Run security checker |
| 72 | + run: composer require --dev enlightn/security-checker && vendor/bin/security-checker security:check |
| 73 | + |
| 74 | + run-tests: |
| 75 | + needs: check-dependencies |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v3 |
| 81 | + |
| 82 | + - name: Setup PHP |
| 83 | + uses: shivammathur/setup-php@v2 |
| 84 | + with: |
| 85 | + php-version: '7.4' |
| 86 | + coverage: pcov |
| 87 | + ini-values: zend.assertions=1 |
| 88 | + |
| 89 | + - name: Install Composer dependencies |
| 90 | + run: composer install |
| 91 | + |
| 92 | + - name: Run PHPUnit |
| 93 | + run: vendor/bin/phpunit --coverage-clover=coverage.xml |
| 94 | + |
| 95 | + - name: Upload coverage report to Codecov |
| 96 | + uses: codecov/codecov-action@v3 |
| 97 | + with: |
| 98 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 99 | + file: coverage.xml |
| 100 | + fail_ci_if_error: true |
| 101 | + |
| 102 | + - name: Upload coverage report to Code Climate |
| 103 | + uses: paambaati/codeclimate-action@v3.2.0 |
| 104 | + env: |
| 105 | + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
| 106 | + with: |
| 107 | + coverageLocations: ${{github.workspace}}/coverage.xml:clover |
| 108 | + |
| 109 | + create-release: |
| 110 | + needs: run-tests |
| 111 | + runs-on: ubuntu-latest |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Checkout code |
| 115 | + uses: actions/checkout@v3 |
| 116 | + |
| 117 | + - name: Setup PHP |
| 118 | + uses: shivammathur/setup-php@v2 |
| 119 | + with: |
| 120 | + php-version: '7.4' |
| 121 | + |
| 122 | + - name: Install Composer dependencies |
| 123 | + run: composer install --no-dev |
| 124 | + |
| 125 | + - name: Get current version |
| 126 | + id: current-version |
| 127 | + run: | |
| 128 | + VERSION=$(composer config version --quiet) |
| 129 | + echo "Current version: $VERSION" |
| 130 | + echo "::set-output name=version::$VERSION" |
| 131 | +
|
| 132 | + - name: Create Release |
| 133 | + id: create-release |
| 134 | + uses: actions/create-release@v1 |
| 135 | + env: |
| 136 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + with: |
| 138 | + tag_name: v${{ steps.current-version.outputs.version }} |
| 139 | + release_name: Release v${{ steps.current-version.outputs.version }} |
| 140 | + body: 'New release for version ${{ steps.current-version.outputs.version }}' |
| 141 | + draft: false |
| 142 | + prerelease: false |
0 commit comments