Skip to content

Commit

Permalink
Add manifest and license to PHAR
Browse files Browse the repository at this point in the history
  • Loading branch information
villfa authored Jan 25, 2022
1 parent 4b0155d commit 5618f16
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ churn.yml export-ignore
CONTRIBUTING.md export-ignore
img/ export-ignore
Makefile export-ignore
manifest.xml export-ignore
phpcs.xml export-ignore
phpmd.xml export-ignore
phpstan.neon export-ignore
Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,28 +237,18 @@ jobs:
composer-${{ runner.os }}-
composer-
- name: "Install dependencies"
run: |
composer config platform.php 7.1.3
composer update --no-dev --no-interaction --no-progress --prefer-dist
composer config --unset platform.php
- name: "Download Box"
- name: "Build Phar"
run: |
curl -sL https://github.com/box-project/box/releases/download/3.9.1/box.phar -o box.phar
chmod +x box.phar
- name: "Validate box configuration"
run: ./box.phar validate

- name: "Compile"
run: ./box.phar compile
make build
mv build/churn.phar .
- name: "Test Version"
run: diff -u <(bin/churn -V) <(./churn.phar -V)
run: |
diff -u <(build/bin/churn -V) <(./churn.phar -V)
./churn.phar --version | grep -E '^churn-php .+@[0-9a-z]{7}$'
- name: "Test Phar"
run: diff -u <(bin/churn --format=csv | sort) <(./churn.phar --format=csv | sort)
run: diff -u <(build/bin/churn --format=csv | sort) <(./churn.phar --format=csv | sort)

- name: "Save Phar"
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -302,4 +292,4 @@ jobs:
- name: Test churn.phar error message
run: |
php -r "passthru('./churn.phar', \$code); if (\$code !== 1) exit('Invalid error code. Expected 1, got ' . \$code);" > error
grep 'The application requires the version ">=7.1.3" or greater' error
grep 'The application requires the version ">=7.1.3" or greater' error
15 changes: 3 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,10 @@ jobs:
content="${content//$'\r'/'%0D'}"
echo "::set-output name=message::$content"
- name: "Install dependencies"
- name: "Build PHAR"
run: |
composer config platform.php 7.1.3
composer update --no-dev --no-interaction --no-progress --prefer-dist
composer config --unset platform.php
- name: "Download Box"
run: |
curl -sL https://github.com/box-project/box/releases/download/3.9.1/box.phar -o box.phar
chmod +x box.phar
- name: "Compile PHAR"
run: ./box.phar compile
make build
mv build/churn.phar .
- name: "Sign PHAR"
run: echo "$GPG_PASSPHRASE" | gpg --pinentry-mode=loopback --passphrase-fd 0 -u [email protected] --output churn.phar.asc --detach-sign churn.phar
Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DEFAULT_GOAL := help
SHELL := /bin/bash

COMPOSER_BIN ?= composer
PHP_BIN ?= php
Expand All @@ -17,17 +18,20 @@ help:
box: ## Download box.phar
box:
test -e build/box.phar || curl -sL https://github.com/box-project/box/releases/download/3.9.1/box.phar -o build/box.phar
chmod +x build/box.phar

.PHONY: build
build: ## Build churn.phar
build: box
scp -r src bin composer.json box.json.dist build/
scp -r src bin composer.json box.json.dist manifest.xml LICENSE.md build/
$(COMPOSER_BIN) config platform.php 7.1.3 --working-dir=build/
$(COMPOSER_BIN) update --no-dev --no-interaction --prefer-dist --working-dir=build/
CHURN_VERSION=$$( $(PHP_BIN) build/bin/churn --version --no-ansi | grep -Po '(?<= )[^@]+' ) ;\
sed -i -e "s@dev-master@$${CHURN_VERSION}@g" build/manifest.xml
$(PHP_BIN) build/box.phar validate build/box.json.dist
$(PHP_BIN) build/box.phar compile --working-dir=build/

.PHONY: clean
clean: ## Clean the build folder
clean:
rm -rf build/src build/bin build/composer.json build/box.json.dist build/vendor build/composer.lock build/box.phar build/churn.phar

(cd build && rm -rf src bin composer.json box.json.dist manifest.xml LICENSE.md vendor composer.lock box.phar churn.phar)
4 changes: 4 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"KevinGH\\Box\\Compactor\\Php"
],
"dump-autoload": false,
"files-bin": [
"LICENSE.md",
"manifest.xml"
],
"finder": [
{
"in": "bin"
Expand Down
13 changes: 13 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="bmitch/churn-php" version="dev-master" type="application" />
<copyright>
<author name="Bill Mitchell" email="[email protected]"/>
<license type="MIT" url="https://github.com/bmitch/churn-php/blob/master/LICENSE.md"/>
</copyright>
<require>
<php version="^7.1 || ^8.0">
<ext name="json"/>
</php>
</requires>
</phar>

0 comments on commit 5618f16

Please sign in to comment.