Skip to content

Commit a849725

Browse files
author
Andreas Frömer
committed
Add automatic phar release build and cleanup
Signed-off-by: Andreas Frömer <[email protected]>
1 parent 1b0f813 commit a849725

File tree

7 files changed

+136
-66
lines changed

7 files changed

+136
-66
lines changed

.github/workflows/release-phar.yml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: "Release Phar"
2+
3+
on:
4+
push:
5+
tags:
6+
- "**"
7+
8+
env:
9+
COMPOSER_VERSION: "2.0.13"
10+
PHP_EXTENSIONS: "mbstring, ds"
11+
PHP_INI_VALUES: "memory_limit=-1, phar.readonly=0"
12+
13+
jobs:
14+
release:
15+
name: "Release"
16+
17+
runs-on: "ubuntu-latest"
18+
19+
strategy:
20+
matrix:
21+
php-version:
22+
- "7.4"
23+
24+
env:
25+
COMPOSER_UNUSED_PHAR: "build/composer-unused.phar"
26+
COMPOSER_UNUSED_PHAR_SIGNATURE: "build/composer-unused.phar.asc"
27+
28+
steps:
29+
- name: "Checkout"
30+
uses: "actions/[email protected]"
31+
32+
- name: "Install PHP with extensions"
33+
uses: "shivammathur/[email protected]"
34+
with:
35+
coverage: "none"
36+
tools: "composer"
37+
extensions: "${{ env.PHP_EXTENSIONS }}"
38+
ini-values: "${{ env.PHP_INI_VALUES }}"
39+
php-version: "${{ matrix.php-version }}"
40+
41+
- name: "Require composer/composer"
42+
run: "composer require composer/composer:${{ env.COMPOSER_VERSION }} --no-interaction --no-progress"
43+
44+
- name: "Remove dev dependencies"
45+
run: "composer install --no-progress --no-dev --prefer-dist --optimize-autoloader"
46+
47+
- name: "Validate configuration for humbug/box"
48+
run: ".phive/box.phar validate box.json"
49+
50+
- name: "Compile composer-unused.phar with humbug/box"
51+
run: ".phive/box.phar compile --config=box.json"
52+
53+
- name: "Show info about composer-unused.phar with humbug/box"
54+
run: ".phive/box.phar info ${{ env.COMPOSER_UNUSED_PHAR }}"
55+
56+
- name: "Validate composer-unused.phar against code"
57+
run: "php ${{ env.COMPOSER_UNUSED_PHAR }} --excludeDir=data"
58+
59+
- name: "Import GPG key"
60+
id: "import_gpg"
61+
uses: "crazy-max/ghaction-import-gpg@v3"
62+
with:
63+
gpg-private-key: "${{ secrets.GPG_PRIVATE_KEY }}"
64+
passphrase: "${{ secrets.GPG_PRIVATE_KEY }}"
65+
66+
- name: "Determine tag"
67+
id: "determine-tag"
68+
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""
69+
70+
- name: "Create release"
71+
id: "create-release"
72+
uses: "actions/[email protected]"
73+
env:
74+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
75+
with:
76+
draft: false
77+
prerelease: false
78+
release_name: "${{ steps.determine-tag.outputs.tag }}"
79+
tag_name: "${{ steps.determine-tag.outputs.tag }}"
80+
81+
- name: "Upload composer-unused.phar"
82+
if: "always()"
83+
uses: "actions/[email protected]"
84+
env:
85+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
86+
with:
87+
asset_content_type: "text/plain"
88+
asset_name: "composer-unused.phar"
89+
asset_path: "${{ env.COMPOSER_UNUSED_PHAR }}"
90+
upload_url: "${{ steps.create-release.outputs.upload_url }}"
91+
92+
- name: "Upload composer-unused.phar.asc"
93+
if: "always()"
94+
uses: "actions/[email protected]"
95+
env:
96+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
97+
with:
98+
asset_content_type: "text/plain"
99+
asset_name: "composer-unused.phar.asc"
100+
asset_path: "${{ env.COMPOSER_NORMALIZE_PHAR_SIGNATURE }}"
101+
upload_url: "${{ steps.create-release.outputs.upload_url }}"

.github/workflows/validate-phar.yml

-37
This file was deleted.

.gitignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
composer.phar
2-
/vendor/
2+
/vendor
33
composer.lock
4-
cs-check.json
5-
.phpunit.result.cache
6-
/build/
7-
*.phar
4+
/build
5+
/data

.phive/box.phar

1.73 MB
Binary file not shown.

.phive/phars.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="humbug/box" version="^3.13.0" installed="3.13.0" location="./.phive/box.phar" copy="true"/>
4+
</phive>

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"php": ">=7.3 || ^8.0",
2121
"ext-json": "*",
2222
"composer-plugin-api": "^2.0",
23-
"composer/composer": "^2.1.3",
2423
"nikic/php-parser": "^4.12",
2524
"psr/container": "^1.0",
2625
"psr/log": "^1.1 || ^2 || ^3",
@@ -29,6 +28,7 @@
2928
"require-dev": {
3029
"ext-ds": "*",
3130
"ext-zend-opcache": "*",
31+
"composer/composer": "^2.1",
3232
"jangregor/phpstan-prophecy": "^0.8.1",
3333
"phpspec/prophecy-phpunit": "^2.0",
3434
"phpstan/phpstan": "^0.12.93",
@@ -64,7 +64,7 @@
6464
"@analyse",
6565
"@test"
6666
],
67-
"cs-check": "phpcs",
67+
"cs-check": "phpcs --cache=data/cs-check.json",
6868
"cs-fix": "phpcbf",
6969
"test": "phpunit"
7070
},

phpunit.xml

+26-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="phpunit.bootstrap.php" colors="true">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">./src</directory>
6-
</include>
7-
</coverage>
8-
<testsuites>
9-
<testsuite name="integration">
10-
<directory>./tests/Integration</directory>
11-
</testsuite>
12-
<testsuite name="unit">
13-
<directory>./tests/Unit</directory>
14-
</testsuite>
15-
</testsuites>
16-
<groups>
17-
<exclude>
18-
<group>disable</group>
19-
</exclude>
20-
</groups>
21-
<php>
22-
<ini name="date.timezone" value="UTC"/>
23-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="phpunit.bootstrap.php"
5+
colors="true"
6+
cacheResultFile="data/phpunit.result.cache">
7+
<coverage>
8+
<include>
9+
<directory suffix=".php">./src</directory>
10+
</include>
11+
</coverage>
12+
<testsuites>
13+
<testsuite name="integration">
14+
<directory>./tests/Integration</directory>
15+
</testsuite>
16+
<testsuite name="unit">
17+
<directory>./tests/Unit</directory>
18+
</testsuite>
19+
</testsuites>
20+
<groups>
21+
<exclude>
22+
<group>disable</group>
23+
</exclude>
24+
</groups>
25+
<php>
26+
<ini name="date.timezone" value="UTC"/>
27+
</php>
2428
</phpunit>

0 commit comments

Comments
 (0)