|
| 1 | +# https://help.github.com/en/categories/automating-your-workflow-with-github-actions |
| 2 | + |
| 3 | +name: "Compile PHAR" |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - '0.12.*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + compile: |
| 12 | + name: "Compile PHAR" |
| 13 | + runs-on: "ubuntu-latest" |
| 14 | + timeout-minutes: 30 |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: "Checkout" |
| 18 | + uses: "actions/checkout@v2" |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: "Install PHP" |
| 23 | + uses: "shivammathur/setup-php@v2" |
| 24 | + with: |
| 25 | + coverage: "none" |
| 26 | + php-version: "8.0" |
| 27 | + |
| 28 | + - name: "Install dependencies" |
| 29 | + run: "composer install --no-interaction --no-progress --no-suggest" |
| 30 | + |
| 31 | + - name: "Install compiler dependencies" |
| 32 | + run: "composer install --no-interaction --no-progress --no-suggest --working-dir=compiler" |
| 33 | + |
| 34 | + - name: "Transform source code" |
| 35 | + run: php bin/transform-source.php |
| 36 | + |
| 37 | + - name: "Compile PHAR" |
| 38 | + run: php compiler/bin/compile |
| 39 | + |
| 40 | + - name: "Configure GPG signing key" |
| 41 | + run: echo "$GPG_SIGNING_KEY" | base64 --decode | gpg --import --no-tty --batch --yes |
| 42 | + env: |
| 43 | + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} |
| 44 | + |
| 45 | + - name: "Get Git log" |
| 46 | + id: git-log |
| 47 | + 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\//') |
| 48 | + |
| 49 | + - name: "Checkout phpstan-dist" |
| 50 | + uses: "actions/checkout@v2" |
| 51 | + with: |
| 52 | + repository: phpstan/phpstan |
| 53 | + ref: 0.12.x |
| 54 | + path: phpstan-dist |
| 55 | + token: ${{ secrets.PAT }} |
| 56 | + |
| 57 | + - name: "cp PHAR" |
| 58 | + run: cp tmp/phpstan.phar phpstan-dist/phpstan.phar |
| 59 | + |
| 60 | + - name: "Sign PHAR" |
| 61 | + working-directory: phpstan-dist |
| 62 | + run: rm phpstan.phar.asc && gpg --command-fd 0 --pinentry-mode loopback -u "$GPG_ID" --batch --detach-sign --armor --output phpstan.phar.asc phpstan.phar |
| 63 | + env: |
| 64 | + GPG_ID: ${{ secrets.GPG_ID }} |
| 65 | + |
| 66 | + - name: "Verify PHAR" |
| 67 | + working-directory: phpstan-dist |
| 68 | + run: "gpg --verify phpstan.phar.asc" |
| 69 | + |
| 70 | + - name: "Set Git signing key" |
| 71 | + working-directory: phpstan-dist |
| 72 | + run: git config user.signingkey "$GPG_ID" |
| 73 | + env: |
| 74 | + GPG_ID: ${{ secrets.GPG_ID }} |
| 75 | + |
| 76 | + - name: "Configure Git" |
| 77 | + working-directory: phpstan-dist |
| 78 | + run: | |
| 79 | + git config user.email "[email protected]" && \ |
| 80 | + git config user.name "Ondrej Mirtes" |
| 81 | +
|
| 82 | + - name: "Commit PHAR - tag" |
| 83 | + working-directory: phpstan-dist |
| 84 | + run: | |
| 85 | + git add phpstan.phar phpstan.phar.asc && \ |
| 86 | + git commit -S -m "PHPStan ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}" && \ |
| 87 | + git push --quiet origin 0.12.x && \ |
| 88 | + git tag -s ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}" && \ |
| 89 | + git push --quiet origin ${GITHUB_REF#refs/tags/} |
0 commit comments