From 5304a77c27c321ecb0772e68ca4cc0c2976913d8 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 09:37:58 +0200 Subject: [PATCH 1/4] Build phar on release --- .github/workflows/build-release.yml | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/build-release.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..6f1526b --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,54 @@ +name: Build Release + +on: + release: + types: [published] + +jobs: + build: + name: Build PHAR + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP 8.4 + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: phar, zip, json, mbstring + ini-values: phar.readonly=0 + tools: composer:v2 + + - name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Make compile script executable + run: chmod +x compile.sh + + - name: Build PHAR + run: ./compile.sh + + - name: Upload PHAR as release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./clitools.phar + 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 From 7867a1b290d960b55f9246aa4a0f64fbba459468 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 09:41:19 +0200 Subject: [PATCH 2/4] Add GitHub Actions workflow for testing PHAR builds on PRs and pushes - Created test-build.yml workflow that runs on pushes and PRs - Uses PHP 8.4 environment with same build process as release workflow - Uploads built PHAR as artifact for testing (7-day retention) - Includes verification steps to ensure PHAR is functional - Allows testing build process without creating releases --- .github/workflows/test-build.yml | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/test-build.yml diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml new file mode 100644 index 0000000..a99c8f3 --- /dev/null +++ b/.github/workflows/test-build.yml @@ -0,0 +1,70 @@ +name: Test Build + +on: + push: + branches: [ main, master, develop ] + pull_request: + branches: [ main, master, develop ] + +jobs: + test-build: + name: Test PHAR Build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP 8.4 + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: phar, zip, json, mbstring + ini-values: phar.readonly=0 + tools: composer:v2 + + - name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Make compile script executable + run: chmod +x compile.sh + + - name: Build PHAR + run: ./compile.sh + + - name: Verify PHAR exists + run: | + if [ ! -f clitools.phar ]; then + echo "❌ PHAR file was not created" + exit 1 + fi + echo "✅ PHAR file created successfully" + ls -la clitools.phar + + - name: Test PHAR functionality + run: | + echo "Testing PHAR functionality..." + php clitools.phar --version + echo "✅ PHAR file is functional and returns version correctly" + + - name: Upload PHAR as artifact (for testing) + uses: actions/upload-artifact@v3 + with: + name: clitools-phar-test + path: clitools.phar + retention-days: 7 + + - name: Show build summary + run: | + echo "🎉 Build test completed successfully!" + echo "📦 PHAR file size: $(du -h clitools.phar | cut -f1)" + echo "📋 PHAR contents summary:" + php clitools.phar --help | head -10 || echo "Help command not available" \ No newline at end of file From ffbb2fc035a051f750bf3383434356bd5207188c Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 09:42:50 +0200 Subject: [PATCH 3/4] Update GitHub Actions to use non-deprecated versions - Update actions/upload-artifact from v3 to v4 (v3 deprecated Jan 2025) - Update actions/cache from v3 to v4 for better performance - Fixes workflow failure due to deprecated artifact actions --- .github/workflows/build-release.yml | 2 +- .github/workflows/test-build.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 6f1526b..ec3cfb4 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -26,7 +26,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index a99c8f3..42d10a4 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -28,7 +28,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -56,7 +56,7 @@ jobs: echo "✅ PHAR file is functional and returns version correctly" - name: Upload PHAR as artifact (for testing) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: clitools-phar-test path: clitools.phar From 156d94eb666055f30395f8fafe9b2ba52739ed91 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 15 Oct 2025 09:45:53 +0200 Subject: [PATCH 4/4] Fix Composer cache configuration in GitHub workflows - Get cache directory from src/ subdirectory where composer.json is located - Cache both global composer cache and src/vendor directory - Use more specific cache key based on src/composer.json and src/composer.lock - Eliminates 'Path Validation Error' warning in post-job cleanup --- .github/workflows/build-release.yml | 10 +++++++--- .github/workflows/test-build.yml | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index ec3cfb4..07b64ff 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -23,13 +23,17 @@ jobs: - name: Get Composer cache directory id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + run: | + cd src + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies uses: actions/cache@v4 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + path: | + ${{ steps.composer-cache.outputs.dir }} + src/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('src/composer.lock', 'src/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Make compile script executable diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 42d10a4..5b84cea 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -25,13 +25,17 @@ jobs: - name: Get Composer cache directory id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + run: | + cd src + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies uses: actions/cache@v4 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + path: | + ${{ steps.composer-cache.outputs.dir }} + src/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('src/composer.lock', 'src/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Make compile script executable