From 352623773ff73310e6e39ad5532b1e19c90fd711 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sat, 12 Dec 2020 08:45:00 +0100 Subject: [PATCH] Compile PHAR using GitHub Actions --- .github/workflows/phar.yml | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/phar.yml diff --git a/.github/workflows/phar.yml b/.github/workflows/phar.yml new file mode 100644 index 0000000000..3e53e04d54 --- /dev/null +++ b/.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