Skip to content

Commit

Permalink
Compile PHAR using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 12, 2020
1 parent a73b48f commit 3526237
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/phar.yml
@@ -0,0 +1,98 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Compile PHAR"

on:
push:
branches:
- "master"

env:
COMPOSER_ROOT_VERSION: "0.12.x-dev"

jobs:
compile:
name: "Compile PHAR"
runs-on: "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 0

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "7.4"
tools: composer:v1

- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-7.4-composer-${{ hashFiles('**/composer.json') }}"
restore-keys: "php-7.4-composer-"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Install compiler dependencies"
run: "composer install --no-interaction --no-progress --no-suggest --working-dir=compiler"

- name: "Transform source code"
run: php bin/transform-source.php

- name: "Compile PHAR"
run: php compiler/bin/compile

- name: "Configure GPG signing key"
run: echo "$GPG_SIGNING_KEY" | base64 --decode | gpg --import --no-tty --batch --yes
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: "Get Git log"
id: git-log
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\//')

- name: "Checkout phpstan-dist"
uses: "actions/checkout@v2"
with:
repository: phpstan/phpstan
path: phpstan-dist
token: ${{ secrets.PAT }}

- name: "cp PHAR"
run: |
cp tmp/phpstan.phar phpstan-dist/phpstan.phar && \
cp tmp/phpstan.phar phpstan-dist/phpstan
- name: "Sign PHAR"
working-directory: phpstan-dist
run: rm phpstan.phar.asc && gpg --command-fd 0 --pinentry-mode loopback -u "$GPG_ID" --batch --detach-sign --output phpstan.phar.asc phpstan.phar
env:
GPG_ID: ${{ secrets.GPG_ID }}

- name: "Verify PHAR"
working-directory: phpstan-dist
run: "gpg --verify phpstan.phar.asc"

- name: "Set Git signing key"
working-directory: phpstan-dist
run: git config user.signingkey "$GPG_ID"
env:
GPG_ID: ${{ secrets.GPG_ID }}

- name: "Configure Git"
working-directory: phpstan-dist
run: |
git config user.email "ondrej@mirtes.cz" && \
git config user.name "Ondrej Mirtes"
- name: "Commit PHAR"
working-directory: phpstan-dist
run: |
git add phpstan phpstan.phar phpstan.phar.asc && \
git commit -S -m "Updated PHPStan to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}" && \
git push --quiet origin master

0 comments on commit 3526237

Please sign in to comment.