Skip to content

Commit 049d4c6

Browse files
committed
fix
1 parent ba6c124 commit 049d4c6

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/sanitizers.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,23 @@ jobs:
5656
run: |
5757
# Try php.net API first
5858
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)"
60-
archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)"
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
6161
if [ -n "$version" ] && [ "$version" != "null" ] && [ -n "$archive" ] && [ "$archive" != "null" ]; then
6262
echo "version=$version" >> "$GITHUB_OUTPUT"
6363
echo "archive=$archive" >> "$GITHUB_OUTPUT"
6464
exit 0
6565
fi
6666
fi
6767
68+
echo "php.net API unavailable, falling back to GitHub releases..."
69+
6870
# Fallback: use the latest GitHub release from php/php-src
69-
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-")')
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
7076
echo "version=$version" >> "$GITHUB_OUTPUT"
7177
echo "archive=https://github.com/php/php-src/archive/refs/tags/php-${version}.tar.gz" >> "$GITHUB_OUTPUT"
7278
- name: Cache PHP
@@ -84,6 +90,10 @@ jobs:
8490
*) curl -fsSL "${URL}" | tar -zx -C php --strip-components=1 ;;
8591
esac
8692
cd php/
93+
# GitHub source archives don't include ./configure, generate it
94+
if [ ! -f ./configure ]; then
95+
./buildconf -f
96+
fi
8797
./configure \
8898
CFLAGS="$CFLAGS" \
8999
LDFLAGS="$LDFLAGS" \

build-static.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,24 @@ if [ -z "${PHP_VERSION}" ]; then
6363
get_latest_php_version() {
6464
input="$1"
6565
# Try php.net API first
66-
json=$(curl -s "https://www.php.net/releases/index.php?json&version=$input")
67-
latest=$(echo "$json" | jq -r '.version' 2>/dev/null)
68-
69-
if [[ "$latest" == "$input"* ]]; then
70-
echo "$latest"
71-
return
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
7272
fi
7373

7474
# Fallback: use the latest GitHub release from php/php-src
7575
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-\")")
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
7777
fi
7878
if [[ "$latest" == "$input"* ]]; then
7979
echo "$latest"
8080
return
8181
fi
8282

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

0 commit comments

Comments
 (0)