|
| 1 | +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions |
| 2 | + |
| 3 | +name: "Compile PHAR" |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "master" |
| 9 | + |
| 10 | +env: |
| 11 | + COMPOSER_ROOT_VERSION: "0.12.x-dev" |
| 12 | + |
| 13 | +jobs: |
| 14 | + compile: |
| 15 | + name: "Compile PHAR" |
| 16 | + runs-on: "ubuntu-latest" |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: "Checkout" |
| 20 | + uses: "actions/checkout@v2" |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: "Install PHP" |
| 25 | + uses: "shivammathur/setup-php@v2" |
| 26 | + with: |
| 27 | + coverage: "none" |
| 28 | + php-version: "7.4" |
| 29 | + tools: composer:v1 |
| 30 | + |
| 31 | + - name: "Cache dependencies" |
| 32 | + uses: "actions/cache@v2" |
| 33 | + with: |
| 34 | + path: "~/.composer/cache" |
| 35 | + key: "php-7.4-composer-${{ hashFiles('**/composer.json') }}" |
| 36 | + restore-keys: "php-7.4-composer-" |
| 37 | + |
| 38 | + - name: "Install dependencies" |
| 39 | + run: "composer install --no-interaction --no-progress --no-suggest" |
| 40 | + |
| 41 | + - name: "Install compiler dependencies" |
| 42 | + run: "composer install --no-interaction --no-progress --no-suggest --working-dir=compiler" |
| 43 | + |
| 44 | + - name: "Transform source code" |
| 45 | + run: php bin/transform-source.php |
| 46 | + |
| 47 | + - name: "Compile PHAR" |
| 48 | + run: php compiler/bin/compile |
| 49 | + |
| 50 | + - name: "Configure GPG signing key" |
| 51 | + run: echo "$GPG_SIGNING_KEY" | base64 --decode | gpg --import --no-tty --batch --yes |
| 52 | + env: |
| 53 | + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} |
| 54 | + |
| 55 | + - name: "Get Git log" |
| 56 | + id: git-log |
| 57 | + run: echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/phpstan\/phpstan-src\/commit\//') |
| 58 | + |
| 59 | + - name: "Checkout phpstan-dist" |
| 60 | + uses: "actions/checkout@v2" |
| 61 | + with: |
| 62 | + repository: phpstan/phpstan |
| 63 | + path: phpstan-dist |
| 64 | + token: ${{ secrets.PAT }} |
| 65 | + |
| 66 | + - name: "cp PHAR" |
| 67 | + run: | |
| 68 | + cp tmp/phpstan.phar phpstan-dist/phpstan.phar && \ |
| 69 | + cp tmp/phpstan.phar phpstan-dist/phpstan |
| 70 | +
|
| 71 | + - name: "Sign PHAR" |
| 72 | + working-directory: phpstan-dist |
| 73 | + run: rm phpstan.phar.asc && gpg --command-fd 0 --pinentry-mode loopback -u "$GPG_ID" --batch --detach-sign --output phpstan.phar.asc phpstan.phar |
| 74 | + env: |
| 75 | + GPG_ID: ${{ secrets.GPG_ID }} |
| 76 | + |
| 77 | + - name: "Verify PHAR" |
| 78 | + working-directory: phpstan-dist |
| 79 | + run: "gpg --verify phpstan.phar.asc" |
| 80 | + |
| 81 | + - name: "Set Git signing key" |
| 82 | + working-directory: phpstan-dist |
| 83 | + run: git config user.signingkey "$GPG_ID" |
| 84 | + env: |
| 85 | + GPG_ID: ${{ secrets.GPG_ID }} |
| 86 | + |
| 87 | + - name: "Configure Git" |
| 88 | + working-directory: phpstan-dist |
| 89 | + run: | |
| 90 | + git config user.email "ondrej@mirtes.cz" && \ |
| 91 | + git config user.name "Ondrej Mirtes" |
| 92 | +
|
| 93 | + - name: "Commit PHAR" |
| 94 | + working-directory: phpstan-dist |
| 95 | + run: | |
| 96 | + git add phpstan phpstan.phar phpstan.phar.asc && \ |
| 97 | + git commit -S -m "Updated PHPStan to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}" && \ |
| 98 | + git push --quiet origin master |
0 commit comments