Skip to content

Commit b1187c2

Browse files
feat: migrate from MacFJA/PharBuilder to Box (#125)
Replace the unmaintained MacFJA/PharBuilder with Box (humbug/box). Changes: - Add humbug/box ^4.6 as dev dependency - Create box.json configuration with equivalent settings - Simplify build-phar script to use Box - Remove obsolete phar-builder configuration - Add automated PHAR building to release workflow - Update .gitignore for Box artifacts The new workflow automatically builds and uploads har.phar to GitHub releases when a new version is published. --------- Co-authored-by: Claude <[email protected]>
1 parent ed3fa82 commit b1187c2

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

.github/workflows/release-please.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,60 @@ jobs:
1717
outputs:
1818
release_created: ${{ steps.release.outputs.release_created }}
1919
tag_name: ${{ steps.release.outputs.tag_name }}
20+
upload_url: ${{ steps.release.outputs.upload_url }}
2021
steps:
2122
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
2223
id: release
2324
with:
2425
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
2526
# This should match the configuration of your conventional commits
2627
release-type: php
28+
29+
build-phar:
30+
name: Build and Upload PHAR
31+
runs-on: ubuntu-24.04
32+
needs: release-please
33+
if: needs.release-please.outputs.release_created == 'true'
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
38+
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
41+
with:
42+
php-version: '8.2'
43+
extensions: json
44+
tools: composer:v2
45+
46+
- name: Get composer cache directory
47+
id: composer-cache
48+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
49+
50+
- name: Cache dependencies
51+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5
52+
with:
53+
path: ${{ steps.composer-cache.outputs.dir }}
54+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
55+
restore-keys: ${{ runner.os }}-composer-
56+
57+
- name: Install dependencies
58+
run: composer install --prefer-dist --no-progress
59+
60+
- name: Build PHAR
61+
run: php -d phar.readonly=0 vendor/bin/box compile
62+
63+
- name: Verify PHAR
64+
run: |
65+
chmod +x har.phar
66+
./har.phar list
67+
68+
- name: Upload PHAR to Release
69+
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
upload_url: ${{ needs.release-please.outputs.upload_url }}
74+
asset_path: ./har.phar
75+
asset_name: har.phar
76+
asset_content_type: application/octet-stream

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ build
55
vendor
66
.php-cs-fixer.cache
77
har.phar
8+
.box_dump/
9+
.box.cache/

box.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"main": "bin/console",
3+
"output": "har.phar",
4+
"compression": "GZ",
5+
"directories": ["src"],
6+
"finder": [
7+
{
8+
"in": "vendor",
9+
"exclude": [
10+
"Tests",
11+
"tests",
12+
"docs",
13+
"test",
14+
"doc"
15+
]
16+
}
17+
],
18+
"compactors": [
19+
"KevinGH\\Box\\Compactor\\Php"
20+
]
21+
}

composer.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"require-dev": {
2525
"friendsofphp/php-cs-fixer": "3.92.0",
2626
"phpunit/phpunit": "^11||^12",
27-
"guzzlehttp/guzzle": "^7.0"
27+
"guzzlehttp/guzzle": "^7.0",
28+
"humbug/box": "^4.6"
2829
},
2930
"autoload": {
3031
"psr-4": {
@@ -37,15 +38,9 @@
3738
}
3839
},
3940
"scripts": {
40-
"build-phar": "[ -x phar-builder.phar ] || (curl -LOJ https://github.com/MacFJA/PharBuilder/releases/download/0.2.8/phar-builder.phar && chmod +x phar-builder.phar) ; php -dphar.readonly=0 ./phar-builder.phar package composer.json && chmod +x har.phar"
41+
"build-phar": "box compile"
4142
},
4243
"extra": {
43-
"phar-builder": {
44-
"compression": "gzip",
45-
"name": "har.phar",
46-
"output-dir": "./",
47-
"entry-point": "bin/console",
48-
"include": []
49-
}
44+
"composer-version": "^2.8.12"
5045
}
5146
}

0 commit comments

Comments
 (0)