Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions .github/workflows/sanitizers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,30 @@ jobs:
caddy/go.sum
- name: Determine PHP version
id: determine-php-version
env:
GH_TOKEN: ${{ github.token }}
run: |
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it also be good enough to just add an exponential backoff to curl? (1s, 2s, 4s, 8s)

curl --retry 5 -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm nvm. Looks like the specific github runners where the sanitizers are currently running are somehow IP-blocked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's the main issue. This happens frequently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better idea than using github might be falling back to a php mirror. We're running one on phpmirror.static-php.dev now, but it's simple enough to rsync to a vps every few hours.

GitHub tags release earlier or later than actual php.net releases, so it's not optimal.

Copy link
Member Author

@dunglas dunglas Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do mirrors also expose the JSON API?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo version="$(jq -r 'keys[0]' version.json)" >> "$GITHUB_OUTPUT"
echo archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)" >> "$GITHUB_OUTPUT"
# Try php.net API first
if curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json 2>/dev/null; then
version="$(jq -r 'keys[0]' version.json 2>/dev/null)" || true
archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json 2>/dev/null)" || true
if [ -n "$version" ] && [ "$version" != "null" ] && [ -n "$archive" ] && [ "$archive" != "null" ]; then
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "archive=$archive" >> "$GITHUB_OUTPUT"
exit 0
fi
fi

echo "php.net API unavailable, falling back to GitHub releases..."

# Fallback: use the latest GitHub release from php/php-src
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
if [ -z "$version" ] || [ "$version" = "null" ]; then
echo "::error::Failed to determine PHP version from both php.net and GitHub"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "archive=https://github.com/php/php-src/archive/refs/tags/php-${version}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Cache PHP
id: cache-php
uses: actions/cache@v5
Expand All @@ -65,8 +85,16 @@ jobs:
name: Compile PHP
run: |
mkdir php/
curl -fsSL "${URL}" | tar -Jx -C php --strip-components=1
case "${URL}" in
*.xz) curl -fsSL "${URL}" | tar -Jx -C php --strip-components=1 ;;
*) curl -fsSL "${URL}" | tar -zx -C php --strip-components=1 ;;
esac
cd php/
# GitHub source archives don't include ./configure, generate it
if [ ! -f ./configure ]; then
sudo apt-get install -y re2c
./buildconf -f
fi
./configure \
CFLAGS="$CFLAGS" \
LDFLAGS="$LDFLAGS" \
Expand Down
20 changes: 16 additions & 4 deletions build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,26 @@ fi
if [ -z "${PHP_VERSION}" ]; then
get_latest_php_version() {
input="$1"
json=$(curl -s "https://www.php.net/releases/index.php?json&version=$input")
latest=$(echo "$json" | jq -r '.version')
# Try php.net API first
if json=$(curl -fsSL "https://www.php.net/releases/index.php?json&version=$input" 2>/dev/null); then
latest=$(echo "$json" | jq -r '.version' 2>/dev/null) || true
if [[ "$latest" == "$input"* ]]; then
echo "$latest"
return
fi
fi

# Fallback: use the latest GitHub release from php/php-src
if type "gh" >/dev/null 2>&1; then
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
fi
if [[ "$latest" == "$input"* ]]; then
echo "$latest"
else
echo "$input"
return
fi

echo "Failed to determine PHP version from both php.net and GitHub, using default: $input" >&2
echo "$input"
}

PHP_VERSION="$(get_latest_php_version "8.5")"
Expand Down
Loading