Merge pull request #24 from EHER/latest-php

Make latest PHP version available
This commit is contained in:
Óscar de Arriba
2019-10-27 13:11:32 +01:00
committed by GitHub
3 changed files with 22 additions and 18 deletions

View File

@@ -1,18 +1,21 @@
#!/usr/bin/env bash
if [ "$GITHUB_API_USER" = "" ] || [ "$GITHUB_API_KEY" = "" ]; then
auth=""
else
auth="-u $GITHUB_API_USER:$GITHUB_API_KEY"
auth=""
if [ -n "$GITHUB_API_TOKEN" ]; then
auth="-H 'Authorization: token $GITHUB_API_TOKEN'"
fi
sed="sed"
if hash gsed 2>/dev/null; then
sed="gsed"
fi
versions=$(curl $auth -s https://api.github.com/repos/php/php-src/git/refs/tags | # Fetch all tags
grep '"ref":' | # Filter by refs
grep 'php-' | # Filter only those related to php-xxxx
grep -Ev "beta|alpha|RC" | # Remove betas, alphas and RCs
sed 's/\"ref\"://' | # Remove '"ref":'
sed 's/\"refs\/tags\/php-//' | # Remove '"refs/tags/php-"'
sed 's/\",//') # Remove last '",'
$sed 's/\"ref\"://' | # Remove '"ref":'
$sed 's/\"refs\/tags\/php-//' | # Remove '"refs/tags/php-"'
$sed 's/\",//') # Remove last '",'
# As per the documentation, all versions should be in a single line separated
# by spaces. We use `xargs` for this.