File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,10 +51,24 @@ jobs:
5151 caddy/go.sum
5252 - name : Determine PHP version
5353 id : determine-php-version
54+ env :
55+ GH_TOKEN : ${{ github.token }}
5456 run : |
55- curl -fsSL 'https://www.php.net/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"
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)"
60+ archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)"
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+ # 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-")')
70+ echo "version=$version" >> "$GITHUB_OUTPUT"
71+ echo "archive=https://github.com/php/php-src/archive/refs/tags/php-${version}.tar.gz" >> "$GITHUB_OUTPUT"
5872 - name : Cache PHP
5973 id : cache-php
6074 uses : actions/cache@v5
6579 name : Compile PHP
6680 run : |
6781 mkdir php/
68- curl -fsSL "${URL}" | tar -Jx -C php --strip-components=1
82+ case "${URL}" in
83+ *.xz) curl -fsSL "${URL}" | tar -Jx -C php --strip-components=1 ;;
84+ *) curl -fsSL "${URL}" | tar -zx -C php --strip-components=1 ;;
85+ esac
6986 cd php/
7087 ./configure \
7188 CFLAGS="$CFLAGS" \
Original file line number Diff line number Diff line change 6262if [ -z " ${PHP_VERSION} " ]; then
6363 get_latest_php_version () {
6464 input=" $1 "
65+ # Try php.net API first
6566 json=$( curl -s " https://www.php.net/releases/index.php?json&version=$input " )
66- latest=$( echo " $json " | jq -r ' .version' )
67+ latest=$( echo " $json " | jq -r ' .version' 2> /dev/null )
6768
6869 if [[ " $latest " == " $input " * ]]; then
6970 echo " $latest "
70- else
71- echo " $input "
71+ return
7272 fi
73+
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-\" )" )
77+ fi
78+ if [[ " $latest " == " $input " * ]]; then
79+ echo " $latest "
80+ return
81+ fi
82+
83+ echo " $input "
7384 }
7485
7586 PHP_VERSION=" $( get_latest_php_version " 8.5" ) "
You can’t perform that action at this time.
0 commit comments