From f1f49de6f93bebc1197807d421668ab34d168114 Mon Sep 17 00:00:00 2001 From: Anatoliy Melnikov <5785276@gmail.com> Date: Fri, 30 Aug 2024 00:26:25 +0300 Subject: [PATCH] Add release.yaml to build PHAR --- .github/workflows/release.yaml | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..017f52c --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,68 @@ +name: Release + +on: + release: + types: [ created ] + +# See https://stackoverflow.com/a/72408109 +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build-phar: + runs-on: ubuntu-latest + name: Build PHAR + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + ini-values: phar.readonly=0 + tools: composer + coverage: none + + - name: Install Composer dependencies + uses: ramsey/composer-install@v3 + with: + composer-options: '--no-dev' + + - name: Build PHAR + run: composer build + + # Smoke test. + # It is recommended ot have some sorts of tests for your PHAR. + #- name: Ensure the PHAR works + # run: pcsf-baseline.phar --version + + # The following section is done only for releases + - name: Import GPG key + if: github.event_name == 'release' + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_KEY_83F9945BC33EC39E9710206C8B4927076BA50A83 }} + passphrase: "${{ secrets.GPG_KEY_83F9945BC33EC39E9710206C8B4927076BA50A83_PASSPHRASE }}" + + - name: Sign the PHAR + if: github.event_name == 'release' + run: | + gpg --local-user 83F9945BC33EC39E9710206C8B4927076BA50A83 \ + --batch \ + --yes \ + --passphrase="${{ secrets.GPG_KEY_83F9945BC33EC39E9710206C8B4927076BA50A83_PASSPHRASE }}" \ + --detach-sign \ + --output pcsf-baseline.phar.asc \ + pcsf-baseline.phar + + - name: Upload PHAR to the release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: | + pcsf-baseline.phar + pcsf-baseline.phar.asc