From 627dde1d75c63b98352c37cbe438c58ba19b30e3 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Sat, 10 Apr 2021 02:10:58 +0200 Subject: [PATCH] feat: extract PHP version restrictions --- Makefile | 3 ++ scripts/extract-php-version-constraints.sh | 32 ++++++++++++++++++++++ scripts/update-version-compat.sh | 21 ++++++++++++++ 3 files changed, 56 insertions(+) create mode 100755 scripts/extract-php-version-constraints.sh create mode 100755 scripts/update-version-compat.sh diff --git a/Makefile b/Makefile index 83d1e8f4..974b8d76 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ update-release: update-rss: ./scripts/update-rss.sh +update-version-compat: + ./scripts/update-version-compat.sh + tag: ./scripts/tag-release.sh diff --git a/scripts/extract-php-version-constraints.sh b/scripts/extract-php-version-constraints.sh new file mode 100755 index 00000000..9471c838 --- /dev/null +++ b/scripts/extract-php-version-constraints.sh @@ -0,0 +1,32 @@ +#!/bin/bash +## +# @license http://unlicense.org/UNLICENSE The UNLICENSE +# @author William Desportes +## + +if ! command -v jq &> /dev/null +then + echo "jq could not be found" + exit 1 +fi + +set -e + +git checkout -q gh-pages > /dev/null + +# Only normal releases +FOUND_PHARS="$(find ./releases/ -type f -name 'VERSION' -not -path '*-dev/*' -not -path '*/dev/*' -not -path '*/latest/*' | sort -n)" + +VERSION_COMPAT='{}' + +for file in $FOUND_PHARS; do + VERSION="$(cat "$file")" + COMPOSER_JSON="$(git show "v${VERSION}:./composer.json")" + REQUIRED_VERSION="$(printf '%s' "${COMPOSER_JSON}" | jq -r .require.php)" + VERSION_COMPAT="$(echo "${VERSION_COMPAT} {\"${VERSION}\": \"${REQUIRED_VERSION}\"}" | jq -s add)" +done + +printf '%s' "${VERSION_COMPAT}" | jq -r + +git checkout -q - > /dev/null + diff --git a/scripts/update-version-compat.sh b/scripts/update-version-compat.sh new file mode 100755 index 00000000..5180eea6 --- /dev/null +++ b/scripts/update-version-compat.sh @@ -0,0 +1,21 @@ +#!/bin/bash +## +# @license http://unlicense.org/UNLICENSE The UNLICENSE +# @author William Desportes +## + +set -e + +VERSIONS_COMPAT="$(./scripts/extract-php-version-constraints.sh)" + +git checkout gh-pages + +printf '%s\n' "${VERSIONS_COMPAT}" > versions-platform-compatibility.json +# Parsing check +jq -r '.' versions-platform-compatibility.json > /dev/null + +# Commit the changes +git add -A "versions-platform-compatibility.json" +git commit -S -m "Update the version compatibility file" -m "#versions-compat" + +git checkout -