Skip to content

Commit 4f55262

Browse files
authored
Merge pull request #105 from BrianHenryIE/create-phar
Create phar and attach to releases
2 parents 30a8a0d + 7c6e9f2 commit 4f55262

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
1-
name: Publish release to Docker Hub
1+
name: Build, tag and attach releases
22

33
on: release
44

55
jobs:
6+
create-phar:
7+
runs-on: ubuntu-latest
8+
name: Create Mozart phar
9+
steps:
10+
- uses: actions/checkout@v1
11+
12+
- name: Install PHP
13+
uses: shivammathur/[email protected]
14+
with:
15+
php-version: 7.2
16+
17+
- name: Install dependencies
18+
run: composer install --prefer-dist --no-suggest --no-progress
19+
20+
- name: Create .phar
21+
run: |
22+
vendor/bin/phar-composer build .
23+
php mozart.phar --version
24+
25+
- uses: meeDamian/[email protected]
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
files: mozart.phar
29+
gzip: false
30+
allow_override: true
631
docker:
732
runs-on: ubuntu-latest
33+
name: Create Docker tag
834
steps:
935
- name: Checkout
1036
uses: actions/checkout@v2

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ This gives you a bin file named `mozart` inside your `vendor/bin` directory, aft
3333

3434
After configuring Mozart properly, the `mozart compose` command does all the magic.
3535

36+
### Standalone Phar
37+
`mozart.phar` can be [downloaded from the releases page](https://github.com/coenjacobs/mozart/releases):
38+
39+
```
40+
composer install --no-dev
41+
php mozart.phar compose
42+
```
43+
3644
## Configuration
3745
Mozart requires little configuration. All you need to do is tell it where the bundled dependencies are going to be stored and what namespace they should be put inside. This configuration needs to be done in the `extra` property of your `composer.json` file:
3846

bin/mozart

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
#!/usr/bin/env php
22
<?php
33
call_user_func(function ($version) {
4-
if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
5-
require $autoload;
6-
} elseif (is_file($autoload = getcwd() . '/../../autoload.php')) {
7-
require $autoload;
8-
}
4+
if( ! Phar::running() ) {
5+
if (is_file($autoload = getcwd() . '/vendor/autoload.php')) {
6+
require $autoload;
7+
} elseif (is_file($autoload = getcwd() . '/../../autoload.php')) {
8+
require $autoload;
9+
}
910

10-
if (is_file($autoload = __DIR__ . '/../vendor/autoload.php')) {
11-
require($autoload);
12-
} elseif (is_file($autoload = __DIR__ . '/../../../autoload.php')) {
13-
require($autoload);
14-
} else {
15-
fwrite(STDERR,
16-
'You must set up the project dependencies, run the following commands:' . PHP_EOL .
17-
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
18-
'php composer.phar install' . PHP_EOL
19-
);
20-
exit(1);
11+
if ( is_file( $autoload = __DIR__ . '/../vendor/autoload.php' ) ) {
12+
require( $autoload );
13+
} elseif ( is_file( $autoload = __DIR__ . '/../../../autoload.php' ) ) {
14+
require( $autoload );
15+
} else {
16+
fwrite( STDERR,
17+
'You must set up the project dependencies, run the following commands:' . PHP_EOL .
18+
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
19+
'php composer.phar install' . PHP_EOL
20+
);
21+
exit( 1 );
22+
}
23+
} else {
24+
include 'phar://mozart.phar/vendor/autoload.php';
2125
}
2226

2327
$app = new CoenJacobs\Mozart\Console\Application($version);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
}
2424
},
2525
"require-dev": {
26+
"clue/phar-composer": "^1.2",
2627
"phpunit/phpunit": "^8.5",
2728
"squizlabs/php_codesniffer": "^3.5",
2829
"mheap/phpunit-github-actions-printer": "^1.4",

0 commit comments

Comments
 (0)