From ef2e6fbfbd4ce52ccaf5e12b7909cc0007089c0d Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 12:33:59 +0200 Subject: [PATCH 1/2] Fix phar file not finding the VERSION file --- .github/workflows/build-release.yml | 11 ++++++----- .github/workflows/test-build.yml | 25 +++++++++++++++++++++++++ src/command.php | 2 +- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 07b64ff..36d5edb 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -41,7 +41,12 @@ jobs: - name: Build PHAR run: ./compile.sh - + + - name: Verify PHAR works + run: | + php clitools.phar --version + echo "✅ PHAR file built successfully and is functional" + - name: Upload PHAR as release asset uses: actions/upload-release-asset@v1 env: @@ -52,7 +57,3 @@ jobs: asset_name: clitools.phar asset_content_type: application/octet-stream - - name: Verify PHAR works - run: | - php clitools.phar --version - echo "✅ PHAR file built successfully and is functional" \ No newline at end of file diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 5b84cea..8c08955 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -59,6 +59,31 @@ jobs: php clitools.phar --version echo "✅ PHAR file is functional and returns version correctly" + - name: Test PHAR in isolated environment + run: | + echo "Testing PHAR in isolated environment (moved to temp directory)..." + # Create temp directory and copy PHAR there + TEMP_DIR=$(mktemp -d) + echo "Created temp directory: $TEMP_DIR" + cp clitools.phar "$TEMP_DIR/" + + # Test from temp directory (without VERSION file or source code) + cd "$TEMP_DIR" + echo "Current directory: $(pwd)" + echo "Contents: $(ls -la)" + + # Test version command + php clitools.phar --version + echo "✅ PHAR works correctly from isolated environment" + + # Test help command + php clitools.phar --help > /dev/null + echo "✅ PHAR help command works from isolated environment" + + # Cleanup + rm -rf "$TEMP_DIR" + echo "✅ Cleanup completed" + - name: Upload PHAR as artifact (for testing) uses: actions/upload-artifact@v4 with: diff --git a/src/command.php b/src/command.php index 819d2b8..60f376a 100644 --- a/src/command.php +++ b/src/command.php @@ -25,7 +25,7 @@ // Get version from VERSION file using closure $getVersion = function() { $versionFile = \Phar::running() !== '' - ? dirname(Phar::running(false)) . '/VERSION' + ? 'phar://' . Phar::running(false) . '/VERSION' : dirname(__DIR__) . '/VERSION'; return trim(file_get_contents($versionFile)); }; From 0d69e7272e3e1ba29ace1b7096b2ad270b0c3c7c Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 12:34:12 +0200 Subject: [PATCH 2/2] Add tilde files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f13a73..98dd966 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ src/vendor/* vendor/* .cache *.backup +*~