Skip to content

Commit

Permalink
Add release.yaml to build PHAR
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeliot-Tm committed Aug 29, 2024
1 parent d9359e3 commit f1f49de
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f1f49de

Please sign in to comment.