Skip to content

Commit

Permalink
Merge pull request #186 from koriym/box
Browse files Browse the repository at this point in the history
Generate Phar file
  • Loading branch information
koriym committed Jun 14, 2024
2 parents 54b3ce1 + 5e8b3e8 commit e516dd7
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 342 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release-phar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release PHAR

on:
workflow_dispatch:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: box

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14

- name: Install Dependencies
run: |
composer install --no-dev
cd asd-sync
npm install
cd ..
- name: Build PHAR
run: box compile

- name: Upload PHAR
uses: actions/upload-artifact@v2
with:
name: asd.phar
path: bin/asd.phar

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Download PHAR
uses: actions/download-artifact@v2
with:
name: asd.phar

- name: Attach artifacts to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/asd.phar
asset_name: asd.phar
asset_content_type: application/octet-stream
10 changes: 5 additions & 5 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
tools: cs2pr
coverage: none

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
tools: cs2pr
coverage: none

Expand All @@ -71,7 +71,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.3

- name: Get composer cache directory
id: composer-cache
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.3
coverage: none

- name: Get composer cache directory
Expand All @@ -110,7 +110,7 @@ jobs:
- name: Install dependencies
run: |
composer install --no-interaction --no-progress --prefer-dist
composer require --dev maglnet/composer-require-checker ^3.0
composer require --dev maglnet/composer-require-checker ^3.0 -W
- name: Run composer-require-checker
run: ./vendor/bin/composer-require-checker
Expand Down
6 changes: 5 additions & 1 deletion bin/asd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ try {
exit(1);
}
if ($config->watch) {
chdir(dirname(__DIR__) . '/asd-sync');

$actualPath = Phar::running(false) !== '' ?
dirname(Phar::running(false),2) . '/asd-sync':
dirname(__DIR__) . '/asd-sync';
chdir($actualPath);
$isFirstRun = ! is_dir(dirname(__DIR__) . '/asd-sync/node_modules');
if ($isFirstRun) {
passthru('npm install');
Expand Down
18 changes: 18 additions & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"alias": "asd.phar",
"base-path": "./",
"main": "bin/asd",
"output": "bin/asd.phar",
"directories": [
"asd-sync",
"src",
"src-xml",
"vendor",
"vendor-xml2json"
],
"files": [
"docs/assets/js/asd@0.1.0.js",
"docs/assets/css/main.css",
"vendor/autoload.php"
]
}
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"ext-dom": "*",
"michelf/php-markdown": "^1.9",
"seld/jsonlint": "^1.8",
"koriym/data-file": "^1.0"
"koriym/data-file": "^1.0",
"bamarni/composer-bin-plugin": "^1.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"roave/security-advisories": "dev-master",
"phpunit/phpunit": "^9.6.10"
},
Expand Down Expand Up @@ -62,7 +62,8 @@
"sa": ["psalm --show-info=true", "./vendor/bin/phpstan analyse -c phpstan.neon"],
"metrics": ["./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"],
"phpmd": ["./vendor/bin/phpmd src text ./phpmd.xml"],
"build": ["@cs", "@sa", "@pcov", "@metrics"]
"compile": ["./vendor/bin/box compile"],
"build": ["@cs", "@sa", "@pcov", "@metrics", "@compile"]
},
"config": {
"allow-plugins": {
Expand Down
Loading

0 comments on commit e516dd7

Please sign in to comment.