Skip to content

Commit 06b419a

Browse files
committed
chore: wip
1 parent d71416e commit 06b419a

File tree

5 files changed

+292
-23
lines changed

5 files changed

+292
-23
lines changed

.github/workflows/precompile-php.yml

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ on:
55
branches: [main, develop]
66
paths:
77
- .github/workflows/precompile-php.yml
8-
- 'build-configs/**'
8+
- build-configs/**
9+
- scripts/get-php-versions.ts
10+
- scripts/check-php-updates.ts
911
schedule:
10-
# Build weekly on Sunday at 2 AM UTC to get latest dependencies
11-
- cron: '0 2 * * 0'
12+
# Check for updates daily at 2 AM UTC
13+
- cron: '0 2 * * *'
1214
workflow_dispatch:
1315
inputs:
14-
php_version:
15-
description: PHP Version to build
16-
required: false
17-
default: 8.4.11
18-
type: string
1916
force_rebuild:
20-
description: Force rebuild even if binary exists
17+
description: Force rebuild even if no new versions
2118
required: false
2219
default: false
2320
type: boolean
@@ -28,12 +25,56 @@ env:
2825
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
2926

3027
jobs:
31-
# First job: Get dynamic PHP versions from ts-pkgx
28+
# First job: Check if we need to rebuild based on new PHP versions
29+
check-for-updates:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
rebuild_needed: ${{ steps.check-updates.outputs.rebuild_needed }}
33+
reason: ${{ steps.check-updates.outputs.reason }}
34+
current_versions: ${{ steps.check-updates.outputs.current_versions }}
35+
latest_versions: ${{ steps.check-updates.outputs.latest_versions }}
36+
new_versions: ${{ steps.check-updates.outputs.new_versions }}
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
41+
- name: Setup Bun
42+
uses: oven-sh/setup-bun@v2
43+
with:
44+
bun-version: latest
45+
46+
- name: Check for PHP updates
47+
id: check-updates
48+
run: |
49+
# Check if there are new PHP versions available
50+
UPDATE_CHECK=$(bun scripts/check-php-updates.ts)
51+
52+
# Extract outputs for GitHub Actions
53+
REBUILD_NEEDED=$(echo "$UPDATE_CHECK" | grep "rebuild_needed=" | cut -d'=' -f2)
54+
REASON=$(echo "$UPDATE_CHECK" | grep "reason=" | cut -d'=' -f2-)
55+
CURRENT_VERSIONS=$(echo "$UPDATE_CHECK" | grep "current_versions=" | cut -d'=' -f2-)
56+
LATEST_VERSIONS=$(echo "$UPDATE_CHECK" | grep "latest_versions=" | cut -d'=' -f2-)
57+
NEW_VERSIONS=$(echo "$UPDATE_CHECK" | grep "new_versions=" | cut -d'=' -f2-)
58+
59+
echo "rebuild_needed=$REBUILD_NEEDED" >> $GITHUB_OUTPUT
60+
echo "reason=$REASON" >> $GITHUB_OUTPUT
61+
echo "current_versions=$CURRENT_VERSIONS" >> $GITHUB_OUTPUT
62+
echo "latest_versions=$LATEST_VERSIONS" >> $GITHUB_OUTPUT
63+
echo "new_versions=$NEW_VERSIONS" >> $GITHUB_OUTPUT
64+
65+
echo "$UPDATE_CHECK"
66+
67+
# Second job: Get dynamic PHP versions from ts-pkgx (only if rebuild is needed)
3268
get-php-versions:
69+
needs: check-for-updates
3370
runs-on: ubuntu-latest
71+
if: needs.check-for-updates.outputs.rebuild_needed == 'true' || github.event.inputs.force_rebuild == 'true'
3472
outputs:
3573
php_versions: ${{ steps.get-versions.outputs.php_versions }}
3674
steps:
75+
- name: Checkout repository
76+
uses: actions/checkout@v4
77+
3778
- name: Setup Bun
3879
uses: oven-sh/setup-bun@v2
3980
with:
@@ -47,10 +88,30 @@ jobs:
4788
echo "php_versions=$PHP_VERSIONS" >> $GITHUB_OUTPUT
4889
echo "🔍 Dynamic PHP versions: $PHP_VERSIONS"
4990
91+
# Job to provide feedback when no rebuild is needed
92+
no-rebuild-needed:
93+
needs: check-for-updates
94+
runs-on: ubuntu-latest
95+
if: needs.check-for-updates.outputs.rebuild_needed == 'false' && github.event.inputs.force_rebuild != 'true'
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v4
99+
100+
- name: No rebuild needed
101+
run: |
102+
echo "✅ No rebuild needed"
103+
echo "Reason: ${{ needs.check-for-updates.outputs.reason }}"
104+
echo "Current versions: ${{ needs.check-for-updates.outputs.current_versions }}"
105+
echo "Latest versions: ${{ needs.check-for-updates.outputs.latest_versions }}"
106+
echo ""
107+
echo "The workflow will skip building since no new PHP versions are available."
108+
echo "To force a rebuild, use the 'force_rebuild' input parameter."
109+
50110
# Matrix strategy for building across different platforms and configurations
51111
build-matrix:
52-
needs: get-php-versions
112+
needs: [check-for-updates, get-php-versions]
53113
runs-on: ${{ matrix.os }}
114+
if: needs.check-for-updates.outputs.rebuild_needed == 'true' || github.event.inputs.force_rebuild == 'true'
54115
strategy:
55116
fail-fast: false
56117
matrix:
@@ -876,9 +937,9 @@ jobs:
876937
877938
# Release job to create GitHub releases with binaries
878939
create-release:
879-
needs: [build-matrix, get-php-versions]
940+
needs: [check-for-updates, build-matrix, get-php-versions]
880941
runs-on: ubuntu-latest
881-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
942+
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') && (needs.check-for-updates.outputs.rebuild_needed == 'true' || github.event.inputs.force_rebuild == 'true')
882943

883944
steps:
884945
- name: Checkout repository
@@ -946,11 +1007,11 @@ jobs:
9461007
uses: softprops/action-gh-release@v1
9471008
with:
9481009
tag_name: binaries-${{ github.run_number }}
949-
name: PHP Precompiled Binaries - Build ${{ github.run_number }}
1010+
name: PHP Binaries - Build ${{ github.run_number }}
9501011
body: |
9511012
🚀 **PHP Precompiled Binaries**
9521013
953-
This release contains precompiled PHP binaries optimized for modern PHP usage:
1014+
> This release contains precompiled PHP binaries optimized for modern PHP usage
9541015
9551016
- **Platforms**: Linux (x86_64), macOS (ARM64 & Intel)
9561017
- **PHP Versions**: ${{ fromJSON(steps.get-versions.outputs.php_versions).join(', ') }}
@@ -964,9 +1025,10 @@ jobs:
9641025
- `full-stack`: Complete PHP build with major extensions and database drivers
9651026
9661027
📦 **Usage with Launchpad**:
967-
These binaries are automatically downloaded by Launchpad instead of compiling from source.
1028+
You may use these however, but if you are looking for automation, these binaries are automatically downloaded by Launchpad instead of compiling from source.
9681029
9691030
🔧 **Built from commit**: ${{ github.sha }}
1031+
🔄 **Update Reason**: ${{ needs.check-for-updates.outputs.reason }}
9701032
9711033
See `manifest.json` for detailed information about each binary.
9721034
files: |

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ Launchpad includes several utility scripts for development and maintenance:
9595
# Get latest PHP versions from ts-pkgx registry
9696
bun scripts/get-php-versions.ts
9797

98-
# This script:
99-
# - Fetches latest PHP versions dynamically
100-
# - Generates improved configuration descriptions
101-
# - Outputs JSON for GitHub Actions
102-
# - Creates markdown tables for documentation
98+
# Check if there are new PHP versions available
99+
bun scripts/check-php-updates.ts
100+
101+
# These scripts:
102+
# - Fetch latest PHP versions dynamically
103+
# - Generates configuration descriptions
104+
# - Check if rebuilds are needed
105+
# - Output JSON for GitHub Actions
106+
# - Create markdown tables for documentation
103107
```
104108

105109
## Installation

docs/scripts.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ This document describes the utility scripts available in the Launchpad project f
66

77
### `scripts/get-php-versions.ts`
88

9-
A TypeScript script that dynamically fetches the latest PHP versions from the ts-pkgx registry and generates improved configuration descriptions.
9+
A TypeScript script that dynamically fetches the latest PHP versions from the ts-pkgx registry and generates configuration descriptions.
10+
11+
### `scripts/check-php-updates.ts`
12+
13+
A TypeScript script that checks if there are new PHP versions available and determines if a rebuild is needed. This script is used by the GitHub workflow to avoid unnecessary builds.
1014

1115
#### Usage
1216

1317
```bash
1418
# Run the script to get latest PHP versions and configuration info
1519
bun scripts/get-php-versions.ts
20+
21+
# Check if there are new PHP versions available
22+
bun scripts/check-php-updates.ts
1623
```
1724

1825
#### Features
@@ -25,6 +32,13 @@ bun scripts/get-php-versions.ts
2532
- JSON output for GitHub Actions
2633
- Markdown tables for documentation
2734

35+
#### Update Checking Features
36+
37+
- **Version Comparison**: Compares current versions with latest available versions
38+
- **Smart Rebuild Logic**: Determines if a rebuild is needed based on version changes
39+
- **GitHub Actions Integration**: Provides outputs for workflow decision making
40+
- **Detailed Reporting**: Shows what changed and why a rebuild is needed
41+
2842
#### Output
2943

3044
The script provides three types of output:
@@ -51,6 +65,31 @@ The script provides three types of output:
5165
| `laravel-mysql` | Laravel with MySQL/MariaDB | Laravel applications using MySQL or MariaDB | MySQL, MariaDB |
5266
```
5367

68+
#### Update Check Output
69+
70+
The update checking script provides:
71+
72+
1. **Human-readable summary**:
73+
```
74+
🔍 PHP Version Update Check
75+
76+
📊 Version Comparison:
77+
Current: 8.4.11, 8.3.14, 8.2.26, 8.1.30
78+
Latest: 8.4.11, 8.3.24, 8.2.29, 8.1.32
79+
80+
🔄 Rebuild Required: YES
81+
Reason: New versions available: 8.3.24, 8.2.29, 8.1.32
82+
```
83+
84+
2. **GitHub Actions outputs**:
85+
```
86+
rebuild_needed=true
87+
reason=New versions available: 8.3.24, 8.2.29, 8.1.32
88+
current_versions=["8.4.11","8.3.14","8.2.26","8.1.30"]
89+
latest_versions=["8.4.11","8.3.24","8.2.29","8.1.32"]
90+
new_versions=["8.3.24","8.2.29","8.1.32"]
91+
```
92+
5493
#### Configuration Descriptions
5594

5695
The script provides improved descriptions for all PHP configurations:

0 commit comments

Comments
 (0)