Skip to content

Commit a809afc

Browse files
committed
use phpmirror.static-php.dev instead
1 parent bc3a18e commit a809afc

4 files changed

Lines changed: 11 additions & 50 deletions

File tree

.github/workflows/sanitizers.yaml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,10 @@ jobs:
5151
caddy/go.sum
5252
- name: Determine PHP version
5353
id: determine-php-version
54-
env:
55-
GH_TOKEN: ${{ github.token }}
5654
run: |
57-
# Try php.net API first
58-
if curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json 2>/dev/null; then
59-
version="$(jq -r 'keys[0]' version.json 2>/dev/null)" || true
60-
archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json 2>/dev/null)" || true
61-
if [ -n "$version" ] && [ "$version" != "null" ] && [ -n "$archive" ] && [ "$archive" != "null" ]; then
62-
echo "version=$version" >> "$GITHUB_OUTPUT"
63-
echo "archive=$archive" >> "$GITHUB_OUTPUT"
64-
exit 0
65-
fi
66-
fi
67-
68-
echo "php.net API unavailable, falling back to GitHub releases..."
69-
70-
# Fallback: use the latest GitHub release from php/php-src
71-
version=$(gh release list --repo php/php-src --exclude-drafts --exclude-pre-releases --json tagName --jq '[.[].tagName | select(startswith("php-8.5."))] | first | ltrimstr("php-")') || true
72-
if [ -z "$version" ] || [ "$version" = "null" ]; then
73-
echo "::error::Failed to determine PHP version from both php.net and GitHub"
74-
exit 1
75-
fi
76-
echo "version=$version" >> "$GITHUB_OUTPUT"
77-
echo "archive=https://github.com/php/php-src/archive/refs/tags/php-${version}.tar.gz" >> "$GITHUB_OUTPUT"
55+
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json 2>/dev/null || curl -fsSL 'https://phpmirror.static-php.dev/releases/index.php?json&max=1&version=8.5' -o version.json
56+
echo version="$(jq -r 'keys[0]' version.json)" >> "$GITHUB_OUTPUT"
57+
echo archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)" >> "$GITHUB_OUTPUT"
7858
- name: Cache PHP
7959
id: cache-php
8060
uses: actions/cache@v5
@@ -85,16 +65,9 @@ jobs:
8565
name: Compile PHP
8666
run: |
8767
mkdir php/
88-
case "${URL}" in
89-
*.xz) curl -fsSL "${URL}" | tar -Jx -C php --strip-components=1 ;;
90-
*) curl -fsSL "${URL}" | tar -zx -C php --strip-components=1 ;;
91-
esac
68+
MIRROR_URL=$(echo "${URL}" | sed 's|https://www.php.net|https://phpmirror.static-php.dev|')
69+
(curl -fsSL "${URL}" || curl -fsSL "${MIRROR_URL}") | tar -Jx -C php --strip-components=1
9270
cd php/
93-
# GitHub source archives don't include ./configure, generate it
94-
if [ ! -f ./configure ]; then
95-
sudo apt-get install -y re2c
96-
./buildconf -f
97-
fi
9871
./configure \
9972
CFLAGS="$CFLAGS" \
10073
LDFLAGS="$LDFLAGS" \

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
- name: Download PHP sources
130130
run: |
131131
PHP_VERSION=$(php -r "echo PHP_VERSION;")
132-
wget -q "https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz"
132+
wget -q "https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz" || wget -q "https://phpmirror.static-php.dev/distributions/php-${PHP_VERSION}.tar.gz"
133133
tar xzf "php-${PHP_VERSION}.tar.gz"
134134
echo "GEN_STUB_SCRIPT=${PWD}/php-${PHP_VERSION}/build/gen_stub.php" >> "${GITHUB_ENV}"
135135
- name: Set CGO flags

.github/workflows/windows.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102

103103
- name: Download PHP
104104
run: |
105-
$webContent = Invoke-WebRequest -Uri $env:PHP_DOWNLOAD_BASE -UseBasicParsing
105+
$webContent = Invoke-WebRequest -Uri $env:PHP_DOWNLOAD_BASE
106106
$links = $webContent.Links.Href | Where-Object { $_ -match "php-\d+\.\d+\.\d+-Win32-vs17-x64\.zip$" }
107107
108108
if (-not $links) { throw "Could not find PHP zip files at $env:PHP_DOWNLOAD_BASE" }

build-static.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,14 @@ fi
6262
if [ -z "${PHP_VERSION}" ]; then
6363
get_latest_php_version() {
6464
input="$1"
65-
# Try php.net API first
66-
if json=$(curl -fsSL "https://www.php.net/releases/index.php?json&version=$input" 2>/dev/null); then
67-
latest=$(echo "$json" | jq -r '.version' 2>/dev/null) || true
68-
if [[ "$latest" == "$input"* ]]; then
69-
echo "$latest"
70-
return
71-
fi
72-
fi
65+
json=$(curl -fsSL "https://www.php.net/releases/index.php?json&version=$input" 2>/dev/null || curl -fsSL "https://phpmirror.static-php.dev/releases/index.php?json&version=$input")
66+
latest=$(echo "$json" | jq -r '.version')
7367

74-
# Fallback: use the latest GitHub release from php/php-src
75-
if type "gh" >/dev/null 2>&1; then
76-
latest=$(gh release list --repo php/php-src --exclude-drafts --exclude-pre-releases --json tagName --jq "[.[].tagName | select(startswith(\"php-${input}.\"))] | first | ltrimstr(\"php-\")") || true
77-
fi
7868
if [[ "$latest" == "$input"* ]]; then
7969
echo "$latest"
80-
return
70+
else
71+
echo "$input"
8172
fi
82-
83-
echo "Failed to determine PHP version from both php.net and GitHub, using default: $input" >&2
84-
echo "$input"
8573
}
8674

8775
PHP_VERSION="$(get_latest_php_version "8.5")"

0 commit comments

Comments
 (0)