#!/bin/bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" # you can pass the versions (of Rosariosis) to this file for the initial/re-build versions=("$@") if [ ${#versions[@]} -eq 0 ]; then # get the folders from the current root directory of the project as the versions # if no versions where passed to the file # this is the standard (2021) way fo doing this # see (https://github.com/docker-library/php/blob/master/versions.sh#L38) versions=(*/) # was assume the folders to be correct # and will serve as the rule # so the json is build from that json='{}' else # with the initial/re-build the versions.json is manually set json="$(/dev/null # get the hash sha512=$(sha512sum rosariosis.tar.bz2 | cut -d " " -f 1) # remove the file rm rosariosis.tar.bz2 # set the hash to the JSON if [ -n "$sha512" ] && [ -n "$package" ]; then export sha512 export package doc="$(jq <<<"$doc" -c '.sha512 = env.sha512')" doc="$(jq <<<"$doc" -c '.package = env.package')" fi # get the default php version defaultPHP=$(echo $versionsHelper | jq -r '.[env.version].php') # get the PHP versions phpVersions=$(echo $versionsHelper | jq -r '.[env.version].phpVersions | keys[]' | jq -R -s -c '. / "\n" - [""]') # get the default variant defaultVariant=$(echo $versionsHelper | jq -r '.[env.version].variant') # get the variants variants=$(echo $versionsHelper | jq -r '.[env.version].variants') # get the aliases aliases=$(echo $versionsHelper | jq -r '.[env.version].aliases') # echo some version details echo "### Rosariosis $version.x details" echo "# Version => $fullVersion" echo "# PHP => $phpVersions" echo "# sha512 => $sha512" # build this fullVersion matrix # and add it to the JSON json="$( jq <<<"$json" -c \ --argjson doc "$doc" \ --argjson phpVersions "$phpVersions" \ --argjson aliases "$aliases" \ --argjson variants "$variants" \ --arg defaultPHP "$defaultPHP" \ --arg defaultVariant "$defaultVariant" ' .[env.version] = { version: env.fullVersion, php: $defaultPHP, phpVersions: $phpVersions, variant: $defaultVariant, variants: $variants, aliases: $aliases, } + $doc ' )" done # store the JSON to the file system jq <<<"$json" -S . >versions.json