Skip to content

Commit

Permalink
Merge pull request #316 from maglnet/feature/automatic-phar-release
Browse files Browse the repository at this point in the history
automatic phar creation for releases
  • Loading branch information
Ocramius authored Nov 10, 2021
2 parents 3c34aa1 + 9e29c06 commit 1379c49
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 97 deletions.
68 changes: 23 additions & 45 deletions .github/workflows/phar-creation.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Building Require-Checker phar"
name: "Building Require-Checker phar for release"

on:
pull_request:
release:
types: [published]

jobs:
build:
name: "Building Require-Checker phar"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "7.4"
- "8.0"
operating-system:
- "ubuntu-latest"
runs-on: "ubuntu-latest"

steps:
- name: "Checkout"
Expand All @@ -28,43 +19,30 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
tools: "phing"
coverage: "none"
php-version: "${{ matrix.php-version }}"
php-version: "7.4"
ini-values: memory_limit=-1, phar.readonly=0

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
- name: "Import GPG Key"
run: echo "$PRIVATE_KEY" | gpg --import
env:
PRIVATE_KEY: ${{ secrets.SIGNING_SECRET_KEY }}

- name: "Install highest dependencies"
if: ${{ matrix.dependencies == 'highest' }}
run: "composer update --no-interaction --no-progress --no-suggest"

- name: "Install locked dependencies"
if: ${{ matrix.dependencies == 'locked' }}
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "build via phing"
run: "phing"
- name: "Build and sign phar file via phing"
run: "vendor/bin/phing phar-build phar-sign"

- name: "Upload phar file artifact"
uses: actions/upload-artifact@v2
with:
name: composer-require-checker-${{ matrix.php-version }}.phar
path: build/composer-require-checker.phar
name: composer-require-checker.phar
path: |
build/composer-require-checker.phar
build/composer-require-checker.phar.asc
- name: Upload PHAR to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/composer-require-checker.phar*
file_glob: true
tag: ${{ github.ref }}
10 changes: 4 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
<!-- ============================================ -->
<target name="phar-prepare-dependencies">
<!--install dependencies without development requirements-->
<composer command="install">
<arg value="--no-dev"/>
<arg value="-o"/>
</composer>
<exec command="composer install --no-dev -o" passthru="true" checkreturn="true"/>
</target>

<!-- ============================================ -->
Expand All @@ -55,8 +52,9 @@
<!-- ============================================ -->
<!-- Target: phar-build -->
<!-- ============================================ -->
<target name="phar-build" depends="run-test">
<target name="phar-build" depends="phar-prepare-dependencies">
<!--create the package-->
<mkdir dir="${build-dir}" />
<php expression="file_put_contents('bin/clistub.php', '#!/usr/bin/env php' . chr(10) . Phar::createDefaultStub('bin/composer-require-checker.php'))"/>
<pharpackage basedir="./"
destfile="${build-dir}/${phing.project.name}.phar"
Expand All @@ -74,7 +72,7 @@
</pharpackage>
</target>

<target name="phar-sign" depends="phar-build">
<target name="phar-sign">
<delete file="${build-dir}/${phing.project.name}.phar.asc"/>
<exec executable="gpg" checkreturn="true" passthru="true">
<arg value="--batch" />
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"ext-zend-opcache": "*",
"doctrine/coding-standard": "^9.0.0",
"mikey179/vfsstream": "^1.6.10",
"phing/phing": "^2.17.0",
"phpstan/phpstan": "^1.1.1",
"phpunit/phpunit": "^9.5.10",
"vimeo/psalm": "^4.12.0"
Expand Down
Loading

0 comments on commit 1379c49

Please sign in to comment.